Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > minimal xml parser?

Reply
Thread Tools

minimal xml parser?

 
 
Mike
Guest
Posts: n/a
 
      10-25-2004
Does anyone know of a minimal/mini/tiny/small xml parser
in c? I'm looking for something small that accepts a stream
or string, builds a c structure, and then returns an opaque
pointer to that structure. There should then be a function
to search that structure given the pointer, tag, and an
optional attribute. I'm looking initially at only text data,
no numbers, though eventuall there will be some binary
data (CDATA?).

Thanks.

Mike
 
Reply With Quote
 
 
 
 
Keith M. Corbett
Guest
Posts: n/a
 
      10-25-2004
"Mike" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'm looking initially at only text data,
> no numbers, though eventuall there will be some binary
> data (CDATA?).


XML does not support "binary data" as the term is commonly used. All data
within an XML instance must be valid per the specified character encoding.

You should read the relevant sections of the XML specification before
determining if XML is an appropriate representation for your requirements.

/kmc


 
Reply With Quote
 
 
 
 
Mike
Guest
Posts: n/a
 
      10-25-2004
In article <(E-Mail Removed)>, Keith M. Corbett wrote:
> "Mike" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> I'm looking initially at only text data,
>> no numbers, though eventuall there will be some binary
>> data (CDATA?).

>
> XML does not support "binary data" as the term is commonly used. All data
> within an XML instance must be valid per the specified character encoding.
>
> You should read the relevant sections of the XML specification before
> determining if XML is an appropriate representation for your requirements.
>
> /kmc
>
>


XML has been chosen, I need to write the parser. Oh, and I do not have
to validate the XML, just parse it.

Mike
 
Reply With Quote
 
William Park
Guest
Posts: n/a
 
      10-25-2004
Mike <(E-Mail Removed)> wrote:
> XML has been chosen, I need to write the parser. Oh, and I do not have
> to validate the XML, just parse it.


Expat (www.libexpat.org). Practically every language has some sort of
support for it, even Bash shell.

--
William Park <(E-Mail Removed)>
Open Geometry Consulting, Toronto, Canada
 
Reply With Quote
 
Mike
Guest
Posts: n/a
 
      10-25-2004
In article <(E-Mail Removed)>, William Park wrote:
> Mike <(E-Mail Removed)> wrote:
>> XML has been chosen, I need to write the parser. Oh, and I do not have
>> to validate the XML, just parse it.

>
> Expat (www.libexpat.org). Practically every language has some sort of
> support for it, even Bash shell.
>


Thanks for the expat suggestion. I have also read for libxml. I'd like to
find a few hundred lines of c code to do this.

Mike
 
Reply With Quote
 
Patrick TJ McPhee
Guest
Posts: n/a
 
      10-26-2004
In article <(E-Mail Removed)>,
Mike <(E-Mail Removed)> wrote:
% In article <(E-Mail Removed)>, William Park wrote:
% > Mike <(E-Mail Removed)> wrote:
% >> XML has been chosen, I need to write the parser. Oh, and I do not have
% >> to validate the XML, just parse it.
% >
% > Expat (www.libexpat.org). Practically every language has some sort of
% > support for it, even Bash shell.
% >
%
% Thanks for the expat suggestion. I have also read for libxml. I'd like to
% find a few hundred lines of c code to do this.

I expect that you won't find a conforming XML parser which is a only few
hundred lines long. The smallest conforming parsers I know of are expat
and rxp, and they're in the thousands of lines. There's also tinyxml, which
is not a conforming parser, and which is still in the thousands of lines.

Although the tempation to write a minimal ``parser'' yourself may be
overwhelming, I think you're better off using an existing, conforming,
parser. Otherwise, you will almost certainly end up with a system that
rejects valid XML files, and what's the good of that?


I think you're looking for something like rxp's API.
--

Patrick TJ McPhee
East York Canada
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
Manuel Collado
Guest
Posts: n/a
 
      10-26-2004
Mike wrote:
> Does anyone know of a minimal/mini/tiny/small xml parser
> in c? I'm looking for something small that accepts a stream
> or string, builds a c structure, and then returns an opaque
> pointer to that structure. There should then be a function
> to search that structure given the pointer, tag, and an
> optional attribute. I'm looking initially at only text data,
> no numbers, though eventuall there will be some binary
> data (CDATA?).


You could try Mini-XML. See

http://www.easysw.com/~mike/mxml/

--
To reply by e-mail, please remove the extra dot
in the given address: m.collado -> mcollado

 
Reply With Quote
 
Jeff Kish
Guest
Posts: n/a
 
      10-26-2004
On Mon, 25 Oct 2004 23:50:10 -0000, Mike <(E-Mail Removed)> wrote:

>In article <(E-Mail Removed)>, William Park wrote:
>> Mike <(E-Mail Removed)> wrote:
>>> XML has been chosen, I need to write the parser. Oh, and I do not have
>>> to validate the XML, just parse it.

>>
>> Expat (www.libexpat.org). Practically every language has some sort of
>> support for it, even Bash shell.
>>

>
>Thanks for the expat suggestion. I have also read for libxml. I'd like to
>find a few hundred lines of c code to do this.
>
>Mike

you really need the source code? I'm sure you could find a parser in library form ready for you to
use.
 
Reply With Quote
 
Michael Sweet
Guest
Posts: n/a
 
      10-26-2004
Mike wrote:
> Does anyone know of a minimal/mini/tiny/small xml parser
> in c? I'm looking for something small that accepts a stream
> or string, builds a c structure, and then returns an opaque
> pointer to that structure. There should then be a function
> to search that structure given the pointer, tag, and an
> optional attribute. I'm looking initially at only text data,
> no numbers, though eventuall there will be some binary
> data (CDATA?).


My Mini-XML library might be what you are looking for:

http://www.easysw.com/~mike/mxml/

--
__________________________________________________ ____________________
Michael Sweet, Easy Software Products mike at easysw dot com
Printing Software for UNIX http://www.easysw.com
 
Reply With Quote
 
Michael Sweet
Guest
Posts: n/a
 
      10-26-2004
Patrick TJ McPhee wrote:
> ...
> I expect that you won't find a conforming XML parser which is a only
> few hundred lines long. The smallest conforming parsers I know of are
> expat and rxp, and they're in the thousands of lines. There's also
> tinyxml, which is not a conforming parser, and which is still in the
> thousands of lines.
> ...


It is a myth that conforming XML parsers have to be big; *validating*
parsers, perhaps, but not a simple non-validating parser which
accepts XML syntax and encoding.

Mini-XML started as 696 lines of C code (it has since grown to a
little over 2700 lines of code) and is a fully conformant XML
parser that provides everything except validation (and I'm thinking
how I could do that without bloating it...)

--
__________________________________________________ ____________________
Michael Sweet, Easy Software Products mike at easysw dot com
Printing Software for UNIX http://www.easysw.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XML and Minimal Directed Acyclic Graph Encoding Altu XML 2 11-14-2007 08:33 PM
Different results parsing a XML file with XML::Simple (XML::Sax vs. XML::Parser) Erik Wasser Perl Misc 5 03-05-2006 10:09 PM
NunniMCAX: new minimal xml parser Open Source Roberto Nunnari XML 0 02-26-2004 02:09 PM
new minimal xml parser Open Source Roberto Nunnari C Programming 0 02-26-2004 02:08 PM
MINIMAL xml parser Don HO XML 6 01-06-2004 05:19 AM



Advertisments