473,320 Members | 2,094 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 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 13042
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.