xmlEscapeEntities : char out of range

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.
ambuliAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Infinity08Connect With a Mentor 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*.
0
 
ambuliAuthor Commented:
Thank you?
Does a NULL from database would cause this?
0
 
Infinity08Commented:
>> 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).
0
 
Infinity08Commented:
>> 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.
0
All Courses

From novice to tech pro — start learning today.