PHP xPath parsing xml file problem
It's a long story-better to describe.
Once there was an XML file, the contents of the file are as follows:
Aaa
Bbb
Ccc
Ddd
It is clear that there can be several collection, and there are several category in each collection. And the ID of collection and category is unique, I used to modify the category's node value . Always use XPath for example: To change the value of the category of ID CA1, I can
$xpath->query ("/root/collection/category[@id = '" CA1 "]"); You can then locate the changes.
But, attention, but Ah! It's a turning point!
But now the format of the XML file has changed into:
Aaa
Bbb
On the basis of the previous change to a category can also have N category, so this situation if you change the value of a particular category, I will not. For example, to change the value of the category ID ca4 to XXX, I do not know.
I want to use XPath, but I don't know how to use it.
$xpath->query ("/root/collection/in this I don't know how to write/category[@id = ' aaa ']");
Like before I know collection below must be category and only one layer, so I can easily locate. Now I won't. Please help me. Thank you.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.