Re: [xml] text between marker nodes



Hi Ian,

On Fri, Jan 21, 2011 at 6:31 AM, Ian B  wrote:
I'm trying to parse bible verses from some XML using libxml

Sample XML is:

<book id="GEN">
 <h>Genesis </h>
 <p>
  <c id="1"/>
  <v id="1"/>
  In the beginning God created the heavens and the earth.
  <v id="2"/>
  Now the earth was formless and empty. Darkness was on the surface of the deep. God’s Spirit was hovering 
over the surface of the waters.
 </p>
</book>

You could just grab the next sibling of each v node (perhaps check
that it is of type text).

If you use the xmlReader interface, it's dead easy:

while not eof
  if type==element and name=="v"
    read next node
    if type==text
      // this is it!
    end
  endif
  read next node
end


IMO, the XML is badly organized. It would have been much more logical
for the verse tag to contain the verse. But I guess it's not up to
you.

Csaba
-- 
GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++
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]