Re: [xml] Reading only the text contents of an element



On Thu, Aug 05, 2010 at 03:44:08PM -0700, nkat nkat wrote:
Hi,

I am using the following code to read the element contents from an xml file.
I just need the text content:

But in the output I get empty lines for those elements which do not
have text content but have child elements in them.
How do i avoid those blank lines from being printed. (I am not able to
compare it with a single newline since for each element i get many
newlines)
Please help me out.. Ive been trying to figure it out from the past two days.

they *are* part of the document, even if supposedly there only for
formatting, there is no way libxml2 can guess when finding a text
node with blank content whether it's there for formatting/niceness
or if this is user content.
The application programmer i.e. *you* are the only one knowing if
the text node is part of the application data or not. It's your job
to do the filtering, libxml2 can't do that for you.

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/



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