I am trying to parse data from a xml page through sax parsing technique.The structure of the xml page is
<?xml version="1.0" encoding="UTF-8"?>
<news_magazine>
<latest_news>
<news>
<category_id>5</category_id>
<author>Super Admin</author>
</news>
<news>
<category_id>6</category_id>
<author>user</author>
</news>
</latest_news>
<categories>
<category>
<category_id>5</category_id>
<category_name>cricket</category_name>
</category>
<category>
<category_id>5</category_id>
<category_name>cricket</category_name>
</category>
</categories>
</news_magazine>
Both the news tag and category tag contains category id.How can i take the the category id separately?
Hey you can do this in very simple way. Just maintain a extra variable
when you put conditions in the parser when you get any of “news” or “category” tag than assign that in current_parent.
and when comparing the tag “category_id” than also put condition of current_parent