[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-smalltalk] Help with reading/parsing an XML file in GST 3.2
From: |
Rick Flower |
Subject: |
Re: [Help-smalltalk] Help with reading/parsing an XML file in GST 3.2 |
Date: |
Wed, 05 Sep 2012 08:16:28 -0700 |
User-agent: |
Apple Webmail/0.6 |
Trying one more time -- since part of it got eaten.. I think I forgot
to switch to plain text.. Doh!
The primer I used to build the internal DTD can be found here:
http://www.w3schools.com/dtd/dtd_intro.asp
-------------------------------------------------------------------------------------------------------
Nevermind.. I found that if I changed #processDocumentStream: to
#parse: that it works fine.. I searched the archives the other day but
didn't notice one post from someone else using that method..
So, for completeness for anyone that might come after me here's the
scoop :
With this XML file (for example) :
<?xml version="1.0"?>
<!DOCTYPE identity [
<!ELEMENT identity (name1, name2, name3)>
<!ELEMENT name1(#PCDATA)>
<!ELEMENT name2(#PCDATA)>
<!ELEMENT name3(#PCDATA)>
]>
<identity>
<name1>foo</name1>
<name2>bar</name2>
<name3>baz</name3>
</identity>
You can then use this code to read & parse it :
[PackageLoader fileInPackage: #XML] on: Error do: [:ex | ex return].
...
| stream |
stream := './identity.xml' asFile readStream.
parser := XML.XMLParser new.
parser validate: false.
parser parse: stream.