Re: [xml] xmlTextReaderConstValue



Daniel, you are right in that xmlTextReaderConstValue returns " "(space
char) and not a NULL (my bad). The problem is that prior to calling
xmlTextReaderConstValue, I call xmlTextReaderNodeType to check if the
return value is of type XML_TEXT_NODE. If the so then I call
xmlTextReaderConstValue to read the value.
xmlTextReaderNodeType returns XML_TEXT_NODE (value 3) when there is text
in the entry and XML_DTD_NODE (value 14) when there is space. Since I am
only looking for XML_TEXT_NODE and ignoring XML_DTD_NODE, I do not call
xmlTextReaderConstValue to read the value.
Is it OK then to also accept returns of type XML_DTD_NODE when I am
looking for text and also allow space characters?

Thanks

-----Original Message-----
From: Daniel Veillard [mailto:veillard redhat com] 
Sent: Monday, January 08, 2007 10:27 AM
To: Benyounes, Mohamed
Cc: xml gnome org
Subject: Re: [xml] xmlTextReaderConstValue

On Thu, Jan 04, 2007 at 04:46:53PM -0500, Benyounes, Mohamed wrote:
Hi,

Here is an example of a xml node I am trying to parse: 

<thisNode>  </thisNode>

 

I am using xmlTextReaderConstValue to read the value of thisNode. The
problem is that if the node is made of only 1 or more spaces only,
this
function returns a NULL. My question is, is there another function
that

  WRONG !

paphio:~/XML -> cat tst.xml
<thisNode>  </thisNode>
paphio:~/XML -> gdb xmllint 
GNU gdb Red Hat Linux (6.5-16.el5rh)
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you
are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for
details.
This GDB was configured as "i386-redhat-linux-gnu"...Using host
libthread_db library "/lib/libthread_db.so.1".

(gdb) b xmlTextReaderConstValue
Breakpoint 1 at 0x80efa15: file xmlreader.c, line 3529.
(gdb) r --stream --debug tst.xml
Starting program: /u/veillard/XML/xmllint --stream --debug tst.xml

Breakpoint 1, xmlTextReaderConstValue (reader=0x8732c70) at
xmlreader.c:3529
3529        if (reader == NULL)
(gdb) c
Continuing.
0 1 thisNode 0 0

Breakpoint 1, xmlTextReaderConstValue (reader=0x8732c70) at
xmlreader.c:3529
3529        if (reader == NULL)
(gdb) finish
Run till exit from #0  xmlTextReaderConstValue (reader=0x8732c70)
    at xmlreader.c:3529
0x0804a6a7 in processNode (reader=0x8732c70) at xmllint.c:1728
1728            value = xmlTextReaderConstValue(reader);
Value returned is $1 = (const xmlChar *) 0x87363f4 "  "
(gdb) 

  on the second node, the #text one, the value returned is the text
content
not NULL. I.e. libxml2 operates as expected.

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillard redhat com  | libxml GNOME XML XSLT toolkit
http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/




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