Re: [xml] Getting out of xmlTextReaderReadAttributeValue mode
- From: Csaba Raduly <rcsaba gmail com>
- To: Simon Kågedal Reimer <skagedal gmail com>
- Cc: libxml gnome <xml gnome org>
- Subject: Re: [xml] Getting out of xmlTextReaderReadAttributeValue mode
- Date: Thu, 22 Aug 2013 11:49:22 +0300
Hi Simon,
On Mon, Aug 19, 2013 at 11:54 PM, Simon Kågedal Reimer wrote:
Hi!
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#
example:
http://pastebin.com/xSbaT7cN
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:
http://pastebin.com/kCc1twyB
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
attributes.
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.
Csaba
--
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]