[xml] xmlTextReaderGetAttribute



libxml staff,
I was recently writing some software to parse and validate an xml document and 
then throw it into an sql database.  I ran into the misfourtune of what, as far 
as I can tell, is a problem with the functions in your library that use 
primarily a xmlTextReaderPtr to return the value of an attribute.  I think the 
error is due to a problem with the xmlTextReaderGetAttribute functions because 
if I understand correctly the xmlTextReaderPtr is pointing to an attribute;  I 
invoke one function to retreive the name of the attribute, via the pointer, (I 
believe I was using xmlTextReaderConstName) and then another function to 
reteive the value of the attribute.  The reason I'm sure (99%) that I've 
invoked the xmlTextReaderGetAttribute function properly is that when I run a 
program that simply prints the names and values to the terminal the names of 
all the attributes of tags that contain attributes are being displayed.  The 
values come up as null.  Now correct me if I'm wrong, but if I can see the 
names of attributes that means the pointer is in the proper position, that is 
it points at an attribute.  So if I can see an attribute's name (which I can), 
the call to xmlTextReaderGetAttribute (using the same pointer as when called to 
get the name, prior to incrimenting) should definately show the value of such 
an attribute.
Other things to consider in my question are, I am using the libxml2 library, 
and I am using a %s in my format string to see the value on the screen.  I 
checked and %s has no problem displaying xmlChar * strings anywhere else so I 
certainly don't think that is the problem.  Also, in my letter here when I've 
referred to xmlTextReaderGetAttribute I mean that I've tried all three of the 
functions you provide in the library to access an attribute's value, none of 
them worked.
The major portion of the code I was using was taken from example code on your 
web site: reader2.c.  I simply had added a segment to, upon finding a tag with 
attributes, extract the attribute names and values.  As I said the names are 
being extracted properly so why don't the values show up if I'm using the exact 
same pointer value as I did to get the name.  I'm completely stummped.
If I'm wrong please set me straight, if not please send me information on some 
kind of a quick workaround, I'd really appreciate it.
Thank you for you time and help in this matter,
Sincerely,
Nathan
Nobbe

---------------------------------------------
This message was sent using Endymion MailMan.
http://www.endymion.com/products/mailman/





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