Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

libxml2 and CDATA

303 views
Skip to first unread message

Ni@m

unread,
Dec 31, 2005, 7:37:59 AM12/31/05
to
I have a question - how to get CDATA's length? If it's really
binary(picture for example) will xmlStrlen help me?? I get content of
node with xmlNodeListGetString(document,node->children,1);

Or maybe you can advise smth else?

Michael Rasmussen

unread,
Dec 31, 2005, 7:51:01 AM12/31/05
to

If it is binary data what do you then need the strlen for? Whould it not
be more usefull to have foot print in memory? Eg. use sizeof the returned
pointer.

--
Hilsen/Regards
Michael Rasmussen
http://keyserver.veridis.com:11371/pks/lookup?op=get&search=0xE3E80917

Ni@m

unread,
Jan 1, 2006, 9:02:59 AM1/1/06
to
> Eg. use sizeof the returned pointer.

But in any case sizeof(pointer) will return me size of pointer, but not
size of data that this pointer points on. Sorry for many "point" =).

I know, that standart strlen won't help me, but can xmlStrlen help me?
For now i'm not using xmlStrlen and put got data straight to
std::string and it's seems to be ok, even binary, but i'm not sure
about that variant.

Andrew Taylor

unread,
Jan 3, 2006, 5:32:13 PM1/3/06
to
Ni@m wrote:
> I have a question - how to get CDATA's length? If it's really
> binary(picture for example) will xmlStrlen help me?? I get content of
> node with xmlNodeListGetString(document,node->children,1);

XML documents can't have arbitrary binary characters in them, even in a
CDATA node. See http://www.w3.org/TR/REC-xml/#charsets. In particular,
the ASCII NUL character (value 0) is not allowed.

If you have binary content, it can't appear in a CDATA node and still be
a well-formed XML document. The binary data can be encoded so it
contains only valid characters, for example in base64.

So, yes, xmlStrlen will return the length, in characters, of any valid
CDATA node.

--
Andrew

Ni@m

unread,
Jan 4, 2006, 2:06:01 PM1/4/06
to
>>The binary data can be encoded so it contains only valid characters, for example in base64.

Thank you very much!! It's an idea!!!

0 new messages