Re: XML Parsing

nugatory <nugatory@mindspring.com>
23 Mar 2000 22:33:50 -0500

          From comp.compilers

Related articles
XML Parsing ma9vk@bath.ac.uk (Vassilis Kostakos) (2000-03-11)
Re: XML Parsing rkrayhawk@aol.com (2000-03-21)
Re: XML Parsing nugatory@mindspring.com (nugatory) (2000-03-23)
Re: XML Parsing bcrivat@hotmail.com (Bogdan CRIVAT) (2000-04-01)
| List of all articles for this month |

From: nugatory <nugatory@mindspring.com>
Newsgroups: comp.compilers,comp.compilers.lcc
Date: 23 Mar 2000 22:33:50 -0500
Organization: MindSpring Enterprises
References: 00-03-066
Keywords: parse

Vassilis Kostakos wrote:


> A few questions on XML:
>
> - Where can I find an XML parser that I can use in my PC (Win/Linux)
> - I'm supposed to be working on a parser for XML. I was wondering if I
> could have something such as:
>
> <num>3</num> <op>plus</op> <num>5</num> <op>equal</op>
>
> which would yield as output <num>8</num>


1) You can get a quite satisfactory open source XML parser from
www.apache.org, in either C++ or Java. A Java XML parser is also
available directly from java.sun.com, and you can find pointers to
several more parsers by following links from www.w3.org or
www.xml.org.


2) Not exactly, because it is an XML rule that all valid XML documents
have a single top-level element, and you have four. But something
very similar would be quite easy:


<calculate op="plus">
  <num>3</num>
  <num>5</num>
</calulate>


with a DTD that looks something like:


<!ELEMENT calculate ((num|calculate),(num|calculate))>
<!ELEMENT num (#PCDATA)>
<!ATTLIST calculate op (plus|minus|times|divide) #REQUIRED>


I'm writing that DTD from memory, so if I gribbled the syntax a bit
you'll have to fix it.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.