Re: [xml] xmlNodePtr->content always empty?



Nils Schnabel said:
Hello,

it seems to me as xmlNodePtr->content is always empty, although in
the
document there is something!
My XML-testfile is:

<?xml version="1.0" encoding="UTF-8"?>
<objects>asd</objects>

And now, when I get a xmlNodePtr cur; via XPath, cur->name is right
("objects"), but cur->content is empty or someting like that... I
can't
print it to the screen using cout or use it in any other way, but
cout
behaves weird:

cout << "test: " << cur->content << endl;

leads to "test: ", but no new line at the end.

I hope you can help me! (I know that I'm likely simply to blind or
stupid to see my mistake...)


Thanks,

Nils Schnabel

(I'm  using libxml 2.6.6 on Mandrake Linux 10 CE)

Without looking into your program (and I really don't want to do
that) it's a little hard to guess where you are going wrong, but it
looks as if you are a little confused about nodes and contents.

With your sample file:

bill billsuper work $ cat obj.xml
<?xml version="1.0" encoding="UTF-8"?>
<objects>asd</objects>

I can display the tree structure produced by the library:

bill billsuper work $ xmllint --debug obj.xml
DOCUMENT
version=1.0
encoding=UTF-8
URL=obj.xml
standalone=true
  ELEMENT objects
    TEXT
      content=asd

From this, you can see that the 'objects' node has a child TEXT
node, and it is the content of this child which you are looking for.

HTH

Bill





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