Re: [xml] Getting out of xmlTextReaderReadAttributeValue mode

Hi Simon,

On Mon, Aug 19, 2013 at 11:54 PM, Simon Kågedal Reimer  wrote:

I'm having difficulties using xmlTextReaderReadAttributeValue. It
doesn't seem to work like the equivalent function in ECMA/.NET, at
least as implemented by Mono. Consider the following simple C#

It parses every attribute of every element that has attributes, and
for each attribute print the texts and entity references contained in
that attribute's value. In this case, it just prints "foo" and "bar",
as expected. Now, take a look at the equivalent C code using libxml2:

libxml2 doesn't quite work like that.

Once you called xmlTextReaderRead [optionally check that
xmlTextReaderNodeType() == 1, a.k.a. element ], you should call
xmlTextReaderMoveToFirstAttribute, then
xmlTextReaderMoveToNextAttribute. This would iterate through all the
At the end you should call xmlTextReaderMoveToElement(), and then you
can resume calling xmlTextReaderRead()

Disclaimer: it's been half a year since I've used libxml2; it was in
my previous job.

GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++
The Tao of math: The numbers you can count are not the real numbers.
Life is complex, with real and imaginary parts.
"Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds
"People disagree with me. I just ignore them." -- Linus Torvalds

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