XML String Manipulation <--- Have somebody can help me?

D

dd711

Hello all,.. i need you help. i have XML String like below:

<IONNEX>
<RESULT>
SUCCESS
</RESULT>
<REPORTID>
1202e020-p8822s-370020
</REPORTID>
</IONNEX>

that input is not from xml file. can somebody help me please?

thanks
 
J

Jacob

dd711 said:
Hello all,.. i need you help. i have XML String like below:

<IONNEX>
<RESULT>
SUCCESS
</RESULT>
<REPORTID>
1202e020-p8822s-370020
</REPORTID>
</IONNEX>

that input is not from xml file. can somebody help me please?

What do you want to do with it?
 
B

bugbear

dd711 said:
Hello all,.. i need you help. i have XML String like below:

<IONNEX>
<RESULT>
SUCCESS
</RESULT>
<REPORTID>
1202e020-p8822s-370020
</REPORTID>
</IONNEX>

that input is not from xml file. can somebody help me please?

Guessing wildy...

a javax.xml.parsers.DocumentBuilder,
will parse and InputSource,
InputSource has a constructor that takes a Reader,
and we can use StringReader to make a Reader from a String,

Thus we have (the line from Hell)

org.w3c.dom.Document document = javax.xml.parsers.DocumentBuilderFactory.newInstance().parse(new
org.xml.sax.InputSource(new java.io.StringReader(xmlString)));

HTH (with apologies for typos)

BugBear
 
J

Jacob

bugbear said:
Thus we have (the line from Hell)

:)

I use this all the time, and have yet to figure why
there isn't a:

Document document = DocumentBuilder.parse(String xml);

Actually I find the entire XML API terrible to work with.
The set of methods and their naming makes it awkward to
parse even the simplest XML document.

Was there no review on this before it was released?
 
K

koos

Jacob said:
:)

I use this all the time, and have yet to figure why
there isn't a:

Document document = DocumentBuilder.parse(String xml);

Actually I find the entire XML API terrible to work with.
The set of methods and their naming makes it awkward to
parse even the simplest XML document.

Was there no review on this before it was released?
There was not even a review of the XML-syntax, with its
superfluous end-tags and that horrible tag/attribute ambiguity.
As XML is bloated and stupid, the 'standard' DOM-api is as bloated
as well.

If you have to cope with XML (tomorrow's legacy), try
a simple API like nanoxml, dom4j or jdom.
Or just implement your own simple parser. A StringBuffer
will do most of the time.

koos.
 
B

bugbear

koos said:
There was not even a review of the XML-syntax, with its
superfluous end-tags and that horrible tag/attribute ambiguity.

The end tag stuff was done to make XML simple
to generate and parse.

If you look at SGML (XML's parent) it has (ahem) fairly
complex DTD stuff to allow the omission of trailing
tags.

http://www.astro.gla.ac.uk/users/norman/star/sgml/SSN-70/N-a3b4.html

When SGML was defined, it was considered likely that humans
beings would create it (don't laugh), and therefore convenience
and compactness were design goals.

For simplicity in XML (again. no laughing at the back)
this concept was dropped.

BugBear
 
A

Alex Hunsley

dd711 said:
Hello all,.. i need you help. i have XML String like below:

<IONNEX>
<RESULT>
SUCCESS
</RESULT>
<REPORTID>
1202e020-p8822s-370020
</REPORTID>
</IONNEX>

that input is not from xml file. can somebody help me please?

thanks

It would help if you asked a question apart from "can somebody help me
please?".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top