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

Discussion in 'Java' started by dd711, Sep 30, 2004.

  1. dd711

    dd711 Guest

    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
     
    dd711, Sep 30, 2004
    #1
    1. Advertising

  2. dd711

    Jacob Guest

    dd711 wrote:

    > 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?
     
    Jacob, Sep 30, 2004
    #2
    1. Advertising

  3. dd711

    bugbear Guest

    dd711 wrote:
    > 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
     
    bugbear, Sep 30, 2004
    #3
  4. dd711

    Jacob Guest

    bugbear wrote:

    > 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?
     
    Jacob, Sep 30, 2004
    #4
  5. dd711

    koos Guest

    Jacob <> wrote:
    > bugbear wrote:
    >
    >> 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?
    >

    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.
     
    koos, Sep 30, 2004
    #5
  6. dd711

    bugbear Guest

    koos wrote:
    >>
    >>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.


    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
     
    bugbear, Sep 30, 2004
    #6
  7. dd711

    Alex Hunsley Guest

    dd711 wrote:
    > 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?".
     
    Alex Hunsley, Oct 1, 2004
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shapper
    Replies:
    3
    Views:
    558
    Scott Allen
    Jul 9, 2005
  2. John

    Can somebody help...

    John, Jan 18, 2004, in forum: C++
    Replies:
    3
    Views:
    366
    Thomas Matthews
    Jan 18, 2004
  3. Patrick

    Can somebody help me ?

    Patrick, Aug 4, 2004, in forum: Python
    Replies:
    3
    Views:
    339
  4. Ramon F Herrera
    Replies:
    10
    Views:
    485
    Gordon Beaton
    Dec 14, 2007
  5. Adam Short
    Replies:
    4
    Views:
    220
    Mark Schupp
    Apr 28, 2005
Loading...

Share This Page