Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How can the node with id equals to 2 be gotten using query on DOMXPath in this XML

XML
<?xml version="1.0"?>
<products>
<product id=1>
<name>Grape</name>
</product>
<product id=2>
<name>Apple</name>
</product>
</products>


I know using query("/products/product"); will return both nodes but I want the one with id=2 to be returned. Is this possible?
Posted

1 solution

Find an answer, it should be
PHP
query("/products/product[@id=2]")
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900