On 23 August 2010 10:45, Mike Caron <[email protected]> wrote:
> The other email thread was getting kinda big, and this is tangentially
> related, so here's a separate thread.
>
> TMC, you mentioned that LibXML2 was eating nodes with all whitespace. I am
> unable to reproduce this problem.
>
> Using this document:
>
> <node>
>    text before<child> text inside </child>text after
>    <blanknode>                 </blanknode>
>    </node>
>
> And, this program:
>
> void print_element_names(xmlNode * a_node) {
>    xmlNode *cur_node = NULL;
>
>    for (cur_node = a_node; cur_node; cur_node = cur_node->next) {
>        for(int i = 0; i < indent; i++) printf("  ");
>
>        switch(cur_node->type) {
>            case XML_ELEMENT_NODE:
>                printf("node type: Element, name: %s\n", cur_node->name);
>                break;
>            case XML_TEXT_NODE:
>                printf("node type: Text, content: \"%s\"\n",
> xmlNodeGetContent(cur_node));
>                break;
>        }
>
>        indent++;
>        print_element_names(cur_node->children);
>        indent--;
>    }
> }
>
> (set up code omitted, and in C because that's what the sample I tweaked was
> in)
>
> I got this output:
>
> D:\projects\LibXml2Test>debug\LibXml2Test.exe ws.xml
> node type: Element, name: node
>  node type: Text, content: "
>    text before"
>  node type: Element, name: child
>    node type: Text, content: " text inside "
>  node type: Text, content: "text after
>    "
>  node type: Element, name: blanknode
>    node type: Text, content: "                 "
>  node type: Text, content: "
>    "
>
> So, it appears to be preserving whitespace properly.

Ah! I see what's going. xml2reload was using xmlNodeIsEmpty, which I'd
failed to notice. Knowing that, I managed to get everything working
without quotes.

> Why don't you commit what you have, and I will take a look at it?

OK... you asked for it!
_______________________________________________
Ohrrpgce mailing list
[email protected]
http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org

Reply via email to