michaelrsweet/mxml

mxmlOptionsSetTypeValue(opt, MXML_TYPE_TEXT) can not load node text...

zlifes opened this issue · 3 comments

test xml node like: test text4.

mxmlOptionsSetTypeValue(opt, MXML_TYPE_TEXT) and load xml, the node text1's text is "test", not "test text4".

but Mini-XML v4.0b1 is OK.

Can you provide a complete example file and source code demonstrating the issue you are seeing?

test1.zip
Example files can be found in the attachment test1.xml

source code demonstrating:
mxml_node_t *doc;
mxml_options_t *lvar_xmlopt=mxmlOptionsNew();
mxmlOptionsSetTypeValue(lvar_xmlopt, MXML_TYPE_TEXT);
doc=mxmlLoadFilename(NULL,lvar_xmlopt,"test1.xml");

the node2's text is "test", not "test text3". It seems to have been truncated from whitespace characters.
but Mini-XML v4.0b1 is OK.

try mxmlOptionsSetTypeValue(lvar_xmlopt, MXML_TYPE_OPAQUE), OK, the node2's text is "test text3".

@zlifes This is the most common error made by developers, which is why I talk about it in several places in the Mini-XML programming manual included with the software...

MXML_TYPE_TEXT nodes are whitespace-delimited text fragments ("words"). Each text node has a string value and a boolean whitespace indicator, so for your example there will be 2 value nodes, one for each word.

MXML_TYPE_OPAQUE nodes are literal text strings containing all of the characters between the begin and end tags.

There are times for using both of these types, but in this case it sounds like you want to use MXML_TYPE_OPAQUE.