Re: [xml] XMLReader and distinguish between <a /> and <a></a>



On Sun, Aug 21, 2011 at 10:58 AM, TomÃÅ PospÃÅil  wrote:
Hello LibXML hackers,

I'm using xmlReader for recursive pre order traversal throught XML tree. Everything works well, but during 
testing I faced problem with distinguish between

<doc>
 <e1  />
 <e1  ></e1>
<doc>

both e1 elements are on same level, so I don't know after call xmlTextReaderRead() if isn't XML well formed 
or I have new node on same level.

If xmlTextReaderRead returns 1, then the XML is well formed.


In short I have to know what type element is (short version <a />, or long <a> </a>), how can I 
accomplished that?

For the short version, you'll get a XMLREADER_TYPE_ELEMENT. If you
call xmlReaderIsEmptyElement(), it will return 1. There will be no
XMLREADER_TYPE_END_ELEMENT.
For the long version, you'll get a XMLREADER_TYPE_ELEMENT
(xmlReaderIsEmptyElement() will return 0) and later a
XMLREADER_TYPE_END_ELEMENT.

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]