We help IT Professionals succeed at work.

xmlEscapeEntities : char out of range

ambuli
ambuli asked
on
Hi experts,

I am using libxml2 to generate an XML document containing details read from a database.  The document is correctly created, but I am seeing the above warning message.  Could someone tell me why this is generated.  Thank you.
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2009
Commented:
Did you verify whether the text read from the database contains control characters ? XML only accepts characters over 0x20, and 0x09, 0x0A and 0x0D. So, these are invalid :

        0x00 -> 0x08
        0x0B -> 0x0C
        0x0E -> 0x1F

If your string contains any of these, this error is thrown.

It could also occur in UTF-8 strings. But I assume that's not the case since you're using char*.

Author

Commented:
Thank you?
Does a NULL from database would cause this?
CERTIFIED EXPERT
Top Expert 2009

Commented:
>> Does a NULL from database would cause this?

By NULL do you mean a NULL character ? If so, then that will just be a premature ending of the string.

If you mean NULL as in a NULL pointer :

        char *name = NULL;

then I think that would crash your application (ie. you need to check for NULL).
CERTIFIED EXPERT
Top Expert 2009

Commented:
>> By NULL do you mean a NULL character ? If so, then that will just be a premature ending of the string.

Correction : it depends on how you obtained the length of the string. If you used strlen, then my answer is valid : it will be a premature end if the string.

If however you obtained the length from the database somehow, and there is a NULL character in the middle of the string, then this will indeed cause that error.