php get xml inner tag content
I need to perform an API that it's response is a XML. But the XML values are inside the XML tags.
<example> <item productid = "1" productname = "xxx" cost = "5.3"/> <item productid = "2" productname = "yyy" cost = "4.0"/> <item productid = "3" productname = "zzz" cost = "1.75"/> </example>
Can anyone tell me how can i, move between tags and get elemnt values For example:
example: item: productid -> 1, productname -> xxx, cost -> 5.3 item: productid -> 2, productname -> yyy, cost -> 4.0 item: productid -> 3, productname -> zzz, cost -> 1.75
Not mandatory, you can just get all the children and loop through them, but XPath is more versatile in real world scenarios ( where you have multiple levels of XML nodes ) and is considerably more readable.
Or you could use DOMElement