hi to all m lil bit confuse as m beginner to the xml+xpath. so m sorry if i m unable to ask any kind of wrong question.

now the question is m trying to accessing the name of the of the attribute of xml file using xpath and tyring to print it on the screen using php but m unable to do...

here is the xml statement for which m trying

    <price currency="EUR">9.95</price>
    <description>Not Available</description>
    <category path="Nederlands / Religie &amp; Spiritualiteit / Religie /"></category>

as i want to print out the following attribute name:
Nederlands / Religie &amp; Spiritualiteit / Religie /
for the other information i have done the job but for accessing the category m unable to do so...plz help out me to access the category name.
following is my work done for accessing the mentioned category.

$cat = $xml->xpath("/product[1]/categories/category");
foreach($cat as $category)
        echo 'Category:';
        echo $category.'<br/>';

5 Years
Discussion Span
Last Post by shahai.ali

In your example, the category data is stored in an attribute, rather than within the node itself.

You therefore need to use the XPath: /product[1]/categories/category/@path where the @ shows you want to target an attribute.


thnx blocblue its working perfectly

Edited by shahai.ali

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.