472,377 Members | 1,661 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,377 software developers and data experts.

LF Example parsing XML from a string not a file

Say this may seem odd but I can't find an example of how to parse XML
that is passed in a string and not a file. All the examples assume you
want to parse a file not a a chunk of memory already read in.

Does any one have an example on the web?

Bob
Jul 20 '05 #1
4 12991
Maybe it works the same way in your mysterious programming language (whose
name you don't want us to know ;-) ) as in Java where
you construct InputSource from StringReader
see (look for StringReader)

http://www.ibiblio.org/xml/books/xml....html#d0e10201

with respect,
Toni Uusitalo

"Bob Sparks" <Bo*******@excite.com> wrote in message
news:9b**************************@posting.google.c om...
Say this may seem odd but I can't find an example of how to parse XML
that is passed in a string and not a file. All the examples assume you
want to parse a file not a a chunk of memory already read in.

Does any one have an example on the web?

Bob

Jul 20 '05 #2
Thanks

I did this

docBuilder.parse( new InputSource( new StringReader( userClassTree.toString() ) ) );

Now I need to figure out how to get the parser to decode
"S &amp; M toys" to
"S & M toys" when I getAttribute.

From reading the what Toni provided it looks like I need to setEncoding().

Bob
"Toni Uusitalo" <to**************@luukkudot.kom> wrote in message news:<As**************@reader1.news.jippii.net>...
Maybe it works the same way in your mysterious programming language (whose
name you don't want us to know ;-) ) as in Java where
you construct InputSource from StringReader
see (look for StringReader)

http://www.ibiblio.org/xml/books/xml....html#d0e10201

with respect,
Toni Uusitalo

"Bob Sparks" <Bo*******@excite.com> wrote in message
news:9b**************************@posting.google.c om...
Say this may seem odd but I can't find an example of how to parse XML
that is passed in a string and not a file. All the examples assume you
want to parse a file not a a chunk of memory already read in.

Does any one have an example on the web?

Bob

Jul 20 '05 #3
&whatever; constructs are entities (or < like things which are called
character references), they've got nothing to do with encoding. &amp; and 4
four other
predefined entities SHOULD have been decoded/expanded when your document
has been parsed i.e. you should get your "SAX & Markup toys" properly.
Check you parser's settings if there's something that preserves those
predefined entities.
(my Java xml parsing is a bit rusty at the moment, maybe somebody else could
help)

encoding: to put it short it's format in which you save/serialize your
document. When you load it you must have proper <? xml version="1.0"
encoding="whatever"?> set unless you're using (saved as) UTF-8 which is
default for parser if no encoding is specified.

http://www.ibiblio.org/xml/books/xmljava/ could give you answer on this too,
I recommend reading it, very useful book. reading it might be a bit on the S
&amp; M side for xml beginner in cos it's so detailed, but it's very good
book.

with respect,
Toni Uusitalo

"Bob Sparks" <Bo*******@excite.com> wrote in message
news:9b**************************@posting.google.c om...
Thanks

I did this

docBuilder.parse( new InputSource( new StringReader( userClassTree.toString() ) ) );
Now I need to figure out how to get the parser to decode
"S &amp; M toys" to
"S & M toys" when I getAttribute.

From reading the what Toni provided it looks like I need to setEncoding().

Bob
"Toni Uusitalo" <to**************@luukkudot.kom> wrote in message

news:<As**************@reader1.news.jippii.net>...
Maybe it works the same way in your mysterious programming language (whose name you don't want us to know ;-) ) as in Java where
you construct InputSource from StringReader
see (look for StringReader)

http://www.ibiblio.org/xml/books/xml....html#d0e10201

with respect,
Toni Uusitalo

"Bob Sparks" <Bo*******@excite.com> wrote in message
news:9b**************************@posting.google.c om...
Say this may seem odd but I can't find an example of how to parse XML
that is passed in a string and not a file. All the examples assume you
want to parse a file not a a chunk of memory already read in.

Does any one have an example on the web?

Bob

Jul 20 '05 #4
Something like this ...

Document doc = (new SAXBuilder()).build( new StringReader(xml));
Bo*******@excite.com (Bob Sparks) wrote in message news:<9b**************************@posting.google. com>...
Say this may seem odd but I can't find an example of how to parse XML
that is passed in a string and not a file. All the examples assume you
want to parse a file not a a chunk of memory already read in.

Does any one have an example on the web?

Bob

Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Michael Hogan | last post by:
I want to pars a playlist file for three different varibles, so I can save them as mp3 files. I am using: strTEMPURL = GetUrlSource(Text1.Text) to put the entire .pls file into a strTEMPURL...
5
by: Aleksandar Matijaca | last post by:
Hi there, I am in some need of help. I am trying to parse using the apache sax parser a file that has vaid UTF-8 characters - I keep end up getting a sun.io.MalformedInputException error. ...
2
by: Cigdem | last post by:
Hello, I am trying to parse the XML files that the user selects(XML files are on anoher OS400 system called "wkdis3"). But i am permenantly getting that error: Directory0: \\wkdis3\ROOT\home...
4
by: Gert Van den Eynde | last post by:
Hi all, Could you give me some pointers on how to parse a text input file in C++? Most will be config-file style input (keyword = data), but some maybe 'structures' like material{ name = n,...
3
by: VB Programmer | last post by:
A dropdownlist in my ASP.NET webform needs to be populated from values taken from an XML file. Can someone provide a (simple) sample XML file and a parsing routine using VB.NET? The values...
1
by: Andre Ranieri | last post by:
I'm having trouble programatically inserting an Excel file into an Image column in our CRM package's SQL 2000 database. The function appears to work ok, but when I attempt to access the file through...
1
by: syhzaidi | last post by:
How can we do Parsing of Hexdecimel in C# reading string from stream file for eg.. i have a file like.......... 0f 2f 12 2d 3a.......in hexa decimal save in a file.txt and i m reading it from...
9
by: Paulers | last post by:
Hello, I have a log file that contains many multi-line messages. What is the best approach to take for extracting data out of each message and populating object properties to be stored in an...
3
by: Anup Daware | last post by:
Hi Group, I am facing a strange problem here: I am trying to read xml response from a servlet using XmlTextWriter. I am able to read the read half of the xml and suddenly an exception:...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...
0
by: F22F35 | last post by:
I am a newbie to Access (most programming for that matter). I need help in creating an Access database that keeps the history of each user in a database. For example, a user might have lesson 1 sent...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.