XML TEXT elements ?

I thought I’d log what I’ve done so far…
I downloaded the gzip,iconv and libxml2 libs and the dae progject.
I added the dlls to my path and build a window project that links with the libs. This was all very easy and I’m now able to walk the node list. This took less than an hour.

One thing is I get a lot of nodes with the name TEXT.
Do I just ignore these?

I.e. this is what I see when I scan the cube.xml file:
xmlChildrenNode library
xmlChildrenNode text
xmlChildrenNode light
xmlChildrenNode text
xmlChildrenNode text
xmlChildrenNode library
xmlChildrenNode text
xmlChildrenNode material
xmlChildrenNode text
xmlChildrenNode text
xmlChildrenNode library
xmlChildrenNode text
xmlChildrenNode geometry
xmlChildrenNode text
xmlChildrenNode text
xmlChildrenNode scene
xmlChildrenNode text
xmlChildrenNode node
xmlChildrenNode text
xmlChildrenNode node
xmlChildrenNode text
xmlChildrenNode node
xmlChildrenNode text
xmlChildrenNode text

Cheers
Dave

Hi David,

I think those are the text values of the attributes. Maybe you are not traversing the document structure the way you intended?

A good tool to use to verify your own progress is called xmllint. It comes with libxml2 but may not be installed by default. If you run xmllint --debug cube.xml you will see the correct structure for comparison.


% xmllint --debug cube.xml
DOCUMENT
version=1.0
encoding=utf-8
URL=cube.xml
standalone=true
  ELEMENT DAE
    default namespace href=http://tempuri.org/DAESchema.xsd
    ATTRIBUTE version
      TEXT
        content=0.4.1
    TEXT
      content=
    ELEMENT library
      ATTRIBUTE type
        TEXT
          content=LIGHT
      TEXT
        content=
      ELEMENT light
        ATTRIBUTE name
          TEXT
            content=Lt-Light
        TEXT
          content=
 

… and so forth.

So the TEXT elements are added by the libxml2 parser. That explains a lot.

http://mail.gnome.org/archives/xml/2002-July/msg00023.html

Can I pretty much assume I can ignore them? Its just white space in the file…

Dave

You must not ignore them completely. The text elements are marking the characters that you must preserve. They contain the value string of the element or attribute.

It appears that these text elements produced by libxml do not contribute to the actual document hierarchy. They are not actual XML elements in the file but rather pseudo-elements of the implementation.