Question

I have to get a list of categories from a XML file that contains entries which have as childs some categories. I tried to use the following xPath

feed/entry/category

but I receive categories from both entries. How can i get categories for each entry?

The XML file is:

<?xml version="1.0" encoding="UTF-8"?>
<feed>
    <entry>
        <id>1</id>
        <category term="note"></category>
        <category term="notebook"></category>
    </entry>
    <entry>
        <id>2</id>
        <category term="note1"></category>
        <category term="notebook1"></category>
    </entry>
</feed>
Was it helpful?

Solution

Try

feed/entry[N]/category

to access the categories of a specific entry with N being 1 or 2 in your case (or any other index in the more general case).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top