Re: [xml] Libxml2 Query: How to read the content of a particular node ?
- From: Emmanuel Rodriguez <emmanuel rodriguez gmail com>
- To: Ujjal Saha <ujjalsaha tataelxsi co in>
- Cc: xml gnome org, Palani D <palanid tataelxsi co in>
- Subject: Re: [xml] Libxml2 Query: How to read the content of a particular node ?
- Date: Sat, 18 Jul 2009 19:31:46 +0200
On Sat, Jul 18, 2009 at 6:31 PM, Ujjal Saha
<ujjalsaha tataelxsi co in> wrote:
Hi guys,
Â
I want to read the content of a xml
tag/node. The Node is having child nodes
But I want to read the content of
that node only.
Â
Following two approaches I tried, But
I am unable to get the content of a particular node:
Â
1. When I am calling the API
xmlNodeGetContent, the API is returning
ÂÂÂ the string of the
current node with all its child node. So I am not able to use the
API.
Â
2. When I am trying the access
NodePtr->content [ content field of the node pointer]
ÂÂÂ I am getting
null.
Â
Is there any other way to get the
content of a particular node only.
If you have other particular needs you will need to do it your self. All that you need to do is loop through the children of the node that you want process and to check what kind of element each children is and decide if you want to keep their text value or not. Concatenate the text values of the node types that you think that are worth it and ignore the others. You probably want to keep all XML_TEXT_NODE and XML_CDATA_SECTION_NODE until you find the first XML_ELEMENT_NODE.
--Â
Emmanuel Rodriguez
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]