hi guys so i have a problem with an xml, it has – before node and i dont know how to deal with this properly with xpath, so the xml would look like this
<xml>
<item>
-<description>
-<type>
</type>
</description>
</item>
</xml>
so how can i navigate down to say type in xpath just before anyone wastes any time giving out the wrong answer i have tried the normal method of $xml->item->description->type this does not work in this case i dont know as its not an illegal character in the name how to deal with the – before th nodes
I don’t think it’s a waste of time to point out that
/xml/item/description/typedoes in fact work (in XPath 1.0 and 2.0 in XmlSpy).That said, I think that perhaps you don’t really want those ‘-‘ characters in your xml. Perhaps a better question would be “How do I strip extraneous ‘-‘ characters from xml?”
Edit:
Here’s some PHP adapted from the SimpleXMLElement documentation to show you that I’m not lying:
Outputs:
If you want any further help, please provide a short example that reproduces the issue.
(Apologies if my PHP is bad, I’m a bit rusty)