Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parsing ".xml" file

Status
Not open for further replies.

pj731

Programmer
Sep 2, 2010
3
IN
Hi,

I have a file written in "C". In the same file I want to parse "a.xml" file and want to extract "xyz" values like "twitter", "Facebook" and "myspace"
===================================================
<?xml version="1.0" ?>
<toplevel>
<ABC>
<xyz="twitter" />
<num="50" />
</ABC>
<ABC>
<xyz="facebook" />
<num="50" />
</ABC>
<ABC>
<xyz="myspace" />
<num="50" />
</ABC>
</toplevel>
==================================================

How can I do it in simple way :

1. Do I need to use libxml parser for the same ?
2. If, yes, then is there any way of fucntion on which I can pass file name "a.xml" and extract variable "xyz" and it will return appropriate valuses like facebook, etc.

Thanks
pj
 
don't bother. that is not an xml document.
 
Hi tsuji,

This xml file doesn't have any style information. But can you please let me know where is the error in this document ?

Thanks
PJ
 
These show it is not.
[tt]<xyz="twitter" />
<num="50" />[/tt]
 
Hi tsuji,

Thanks, It was my mistake I sent you wrong file. The correct one is :
===================================================
<?xml version="1.0" ?>
<toplevel>
<ABC>
<xyz data ="twitter" />
<num int ="50" />
</ABC>
<ABC>
<xyz data ="facebook" />
<num int ="50" />
</ABC>
<ABC>
<xyz data ="myspace" />
<num int ="50" />
</ABC>
</toplevel>
==================================================
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top