Re: Attributes and Problems
Brought to you by:
bs_php,
nigelswinson
From: Nigel S. <nig...@us...> - 2002-08-28 23:29:13
|
> I am having slight problems with retrieving attributes. For example: > > if I do something like > $nodenames = $xpath->nodeName("$mypath/*") > while ($nodename = arrayshift($nodenames)){ > echo "This is my node".$nodename; > echo "<br>This is it > attributes".$xpath->getAttributes("$mypath/$nodename"); > } > > Now this works if the nodes are unique in name, but if they have the > same name, I get only the first attribute, but I do get every instance > of the nodes, just the wrong attribute. > > Thanks for any suggestions in advance. Your code looks fine, apart from the fact that you are trying to print an array. Might be better to do: echo "<br>This is it attributes"; print_r($xpath->getAttributes("$mypath/$nodename")); If it really does'nt seem like it is doing what you think it should, could you attach a short xml file and php file, and tell us what you expect the output to be and what the output is? That way we can quickly reproduce your issue and analyse/fix it. Also it would be helpful if you could tell us what version of the class you are using (or what CVS version if you have been using a version straight from CVS). Thanks Nigel |