Re: [xml] How to parse and print data



Thank You John,

I could able to use xpath and used xmlNodeGetContent to get the content of the node.
By using the below API's
 xpathCtx = xmlXPathNewContext(doc);
xpathObj = xmlXPathEvalExpression(xpathExpr, xpathCtx);
Given an _expression_ it gives the property of the node.
for ex: if i give '\\Option' i could able to get English, French etc.
But i dont know how to get Value which is under Option node??

I was wondering is there any API which gives the following information.

  <Option Value="00">English</Option>
  <Option Value="01">French</Option>

If i would like to get the data of the Values which is under node Option how can i get?
What is the way to do this?

-Sam






On Wed, Oct 13, 2010 at 5:11 PM, John Dennis <jdennis redhat com> wrote:
On 10/13/2010 04:58 PM, samaram s wrote:
Hi, Thank you for the link.
Actually i have gone through those sample codes. None of them dealt with
getting the value given a node.
Suppose, provided node as "Prompt" i should able to print the Value,
"System Language" in the below example.
There are lots of API's. unable to locate which one to use.
Could you please give me some idea on it.

That's the "content" of the node, look for the api routines whose names look like GetContent. Really, all this is well documented with loads of examples.

You might want to consider using xpath to extract information out of your documents, it's easy to use and very powerful. Plus it isolates you from a lot of the low level stuff.


    > <?xml version="1.0" encoding="UTF-8"?>
    > <!--Created on Date and Time -->
    > <script>
    > <Question Token="01" Offset="00" Width="02" >
    > <Prompt>SYSTEM LANGUAGE</Prompt>
    > <Option Value="00">English</Option>
    > <Option Value="01">French</Option>
    > <Value>00</Value>
    > </Question>
    > </script>
--
John Dennis <jdennis redhat com>

Looking to carve out IT costs?
www.redhat.com/carveoutcosts/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]