Solved

xml parsing

Posted on 2011-09-13
2
330 Views
Last Modified: 2016-09-30
Hi

I have a string which has the xml content as shown in the code section below...

using libxml2, can you please help me understand how i can extract the values in the url tag and the text tag?

what header files do i need to include?
how do i initialize the xml parser?

my choice  of xml parsers is libxml2 or xerces

i am reading the documentaion, but find it confusing



<ds count="1">
<listing rank="1">
<url>
http://yy.com/ovS7oGf_LJsQjFhhYtClHSt1Q8GNUzc2QwrVO7s2EHmoxg3qVJnhlUg8Rv3F0TdX3qXpT1xTaPPuOoVxXD7CCZRbdlKeVdVbqkq4UL4fMsy3Ukvx6MgOn3mTvP5LzZvmbgjq3B8mAwR9tbhqWmxLYSTo4JageN316hWsKitvHUGK8_R4-QUxbRcAX1sf2rmC3mY6jVUCUzSTGaItyHtT3b83_Qvul8wECZjcz1rdwhfW7z1PqO4ZLkO8n-Oj9JNcdVayDts8dDofdA_bQ
</url>
<text>
Mob Sch Any 1_4
</text>
<site>Mob_Sch_Any_1_4</site>
<description>Mob Sch Any 1_4
</description>
</listing>
</ds>

Open in new window

0
Comment
Question by:Vlearns
2 Comments
 
LVL 53

Accepted Solution

by:
Infinity08 earned 250 total points
ID: 36534462
Have a look at this sample code :

        http://xmlsoft.org/examples/index.html#xpath1.c

Sure, it's quite a bit of code, but that's needed for properly parsing XML :)
0
 
LVL 32

Assisted Solution

by:sarabande
sarabande earned 250 total points
ID: 36536049
at the same site infinit08 has suggested you'll find the tree1.c which has less code.

http://xmlsoft.org/examples/tree1.c

you might succeed by changing the function print_element_names to your purpose.

Sara
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now