473,597 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 13052
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*******@exci te.com> wrote in message
news:9b******** *************** ***@posting.goo gle.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 #2
Thanks

I did this

docBuilder.pars e( new InputSource( new StringReader( userClassTree.t oString() ) ) );

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.ko m> wrote in message news:<As******* *******@reader1 .news.jippii.ne t>...
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*******@exci te.com> wrote in message
news:9b******** *************** ***@posting.goo gle.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 #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="whate ver"?> 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*******@exci te.com> wrote in message
news:9b******** *************** ***@posting.goo gle.com...
Thanks

I did this

docBuilder.pars e( new InputSource( new StringReader( userClassTree.t oString() ) ) );
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.ko m> wrote in message

news:<As******* *******@reader1 .news.jippii.ne t>...
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*******@exci te.com> wrote in message
news:9b******** *************** ***@posting.goo gle.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 #4
Something like this ...

Document doc = (new SAXBuilder()).b uild( new StringReader(xm l));
Bo*******@excit e.com (Bob Sparks) wrote in message news:<9b******* *************** ****@posting.go ogle.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
3898
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 varible. I want to grab .pls files from shoutcast and break them into varibles. ----------------Begin winamp.pls file-------------------
5
14047
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. This is my code:
2
3941
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 Canonicalpath-Directory4: \\wkdis3\ROOT\home\bwe\ You selected the file named AAA.XML getXmlAlgorithmDocument(): IOException Not logged in
4
3510
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, position = x,y,z}. Things that I have in my mind now are: 1) simply reading in strings, analysing the strings myself, 2) writing a lexer/parser, 3) xml parsing, 4) line by line and RegExp.
3
4493
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 could be something like: Fruits Vegetables Meats Dairy
1
13261
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 the application's front end the file appears to be corrupt. The front-end application has a way of inserting files to the column, however when I analyze this in SQL Profiler the contents of the Byte array appear to be quite different than the one...
1
1640
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 the file....... now i have to convert this in decimal and save in an array.of integers.......i thought it can be achieved through parsing ..means 0f could be stored in array converted in decimal...but remmber i m reading from a file///////////////i...
9
1976
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 ArrayList? I have tried looping through the logfile using regex, if statements and flags to find the start and end of each message but I do not see a good time in this process to create a new instance of my Message object. While messing around with...
3
3305
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: “Unexpected end of file while parsing Name has occurred” isbeing thrown. Following is the part o xml I am trying to read: <CHECK_ITEM_OUT>
0
8271
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8258
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6686
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5847
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5426
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3923
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2399
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1493
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1231
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.