Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.development.apps > #719

Re: Failure to extract information using mini-XML v2.8

From Lew Pitcher <lew.pitcher@digitalfreehold.ca>
Subject Re: Failure to extract information using mini-XML v2.8
Newsgroups comp.os.linux.development.apps
References <Sl86v.121102$nm4.66014@fx27.iad> <87lhuu8uyu.fsf@sable.mobileactivedefense.com> <zqd6v.82867$f85.57@fx19.iad> <87ha5i8qb1.fsf@sable.mobileactivedefense.com>
Organization The Pitcher Digital Freehold
Message-ID <25e6v.27397$GL.1776@fx12.iad> (permalink)
Date 2014-04-24 16:02 -0400

Show all headers | View raw


On Thursday 24 April 2014 15:45, in comp.os.linux.development.apps, "Rainer
Weikusat" <rweikusat@mobileactivedefense.com> wrote:

> Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:
>> On Thursday 24 April 2014 14:04, in comp.os.linux.development.apps,
>> "Rainer Weikusat" <rweikusat@mobileactivedefense.com> wrote:
>>
>>> Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:
>>>> While using miniXML v2.8 (http://www.msweet.org/projects.php?Z3) to
>>>> read and process an XML document in a small C program, I came across a
>>>> problem that I cannot surmount.
>>> 
>>> [...]
>>> 
>>>> For my demo, I have a dead simple XML document:
>>>>   <?xml version="1.0" encoding="utf-8"?><document>Hello,
>>>>   World</document>
>>> 
>>> [...]
>>> 
>>>>   #include <stdio.h>
>>>>   #include <stdlib.h>
>>>>
>>>>   #include <mxml.h>
>>>>
>>>>   int main(void)
>>>>   {
>>>>     int rc = EXIT_FAILURE;
>>>>
>>>>     mxml_node_t *xml, *doc;
>>>>     const char *text;
>>>>
>>>>     xml = mxmlLoadFile(NULL,stdin,MXML_TEXT_CALLBACK);
>>>>     doc =
>>>>     mxmlFindElement(xml,xml,"document",NULL,NULL,MXML_DESCEND_FIRST);
>>>>     text = mxmlGetText(doc,NULL);
>>>>
>>>>     if (text)
>>>>     {
>>>>       printf("Success: \"%s\"\n",text);
>>>>       rc = EXIT_SUCCESS;
>>>>     }
>>>>     else puts("Fail");
>>>>
>>>>     return rc;
>>>>   }
>>> 
>>> As determined by examining the mini-XML (2.8) code and testing,
>>> mxmlLoadFile (or, more correctly, the corresponding backend routine)
>>> will only create 'interior value nodes' when the first argument to
>>> mxmlLoadFile is not null.
>>
>> Pardon my reaction, but.... so?
> 
> So it builds a tree structure of XML elements but doesn't include
> anything which is not an XML element in that (because the type is always
> MXML_IGNORE).
> 
>> "interior value nodes" doesn't mean anything to me. Does that mean that
>> miniXML does /not/ provide a way to extract text from XML?
> 
> I've changed the code such that it doesn't force MXML_IGNORE. In this
> case, it creates an empty 'text node' as child of the tree root and two
> 'text nodes' as children of the document node, the first containing the
> string 'Hello,' and the second the string 'World'.
> 
> That's presumably useful for something but likely not for your use case.

So, it would appear that the miniXML mxmlLoadFile() function (and the
other "Load" functions that use the same back-end code) are broken in 2.8,
and it isn't my (albeit inexpert) usercode that screwed up.

Thanks, Rainer, for looking at the code. I have reported the problem on the
miniXML bugs page, updating bug #502 with my test and results. Hopefully,
the author will find a way to fix the issue, else it no longer satisfies
it's use-case (lightweight processing of minimal XML files).

Thanks again
-- 
Lew Pitcher
"In Skills, We Trust"
PGP public key available upon request

Back to comp.os.linux.development.apps | Previous | NextPrevious in thread | Find similar


Thread

Failure to extract information using mini-XML v2.8 Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2014-04-24 09:30 -0400
  Re: Failure to extract information using mini-XML v2.8 Rainer Weikusat <rweikusat@mobileactivedefense.com> - 2014-04-24 19:04 +0100
    Re: Failure to extract information using mini-XML v2.8 Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2014-04-24 15:16 -0400
      Re: Failure to extract information using mini-XML v2.8 Rainer Weikusat <rweikusat@mobileactivedefense.com> - 2014-04-24 20:45 +0100
        Re: Failure to extract information using mini-XML v2.8 Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2014-04-24 16:02 -0400

csiph-web