[xml] Query regarding empty nodes creation during document parsing,



Title: Query regarding empty nodes creation during document parsing,

Hi,

        I have a query regarding the creation of DOM tree when parsing the xml document. I am working on libxml2-2.6.28. I am parsing the document buffer with the API xmlReadMemory( ) with XML_PARSE_NOBLANKS options set.

        However for the xml buffer like,

"<types>\r\n"

           "<schema/>\r\n"

 "</types>\r\n"

        It does not create a blank node, but whereas for the buffer,

        "<types>\r\n"

        "</types>\r\n"

        It does create a blank node as the child of element types. I just had a peed into the parser code, and I have done the following fix to overcome this problem.

static int areBlanks(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,

                     int blank_chars) {

    int i, ret;

xmlNodePtr lastChild;

.

/*

* Check that the string is made of blanks

*/

if (blank_chars == 0) {

for (i = 0;i < len;i++)

            if (!(IS_BLANK_CH(str[i]))) return(0);

}

.

+ for (i = 0;i < len;i++){

+       if (IS_BLANK_CH(str[i]))

+               continue;

+       else

+               break;

+}

+if (i == len) return(1);

        Thanks and Regards,

Nagesh.



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