This discussion is archived
5 Replies Latest reply: May 26, 2009 6:24 AM by 843851 RSS

converting XML to Java in STB

843851 Newbie
Currently Being Moderated
I am trying to convert xml to java. Looking for simple and light way to covert xml to java in STB.
  • 1. Re: converting XML to Java in STB
    843851 Newbie
    Currently Being Moderated
    Basically i am trying to convert following SOAP message response into java.........

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
         <soap:Body>
              <getUserDetail xmlns="http://xav-178:7001/Component/IContentOperationsComponent/">
                   <bookName>k-7 aircraft</bookName>
                   <userName>KBG</userName>
                   <address>Tokyo,Japan</address>
                   <city>Tokyo</city>
                   <versionId>0</versionId>
              </getUserDetail>
         </soap:Body>
    </soap:Envelope>

    Looking for way out.???........
  • 2. Re: converting XML to Java in STB
    843851 Newbie
    Currently Being Moderated
    Heh - all the tags in your question got stripped out by the forum-to-email bridge :-)

    Anyway, basically you just parse the XML data. You can use some
    kind of library if you like, but it turns out that parsing an XML response
    that's consistently formatted the same way isn't all that hard to do directly.

    In the HD cookbook project, we have a sample xlet that does just this, reading
    weather data from some public web service out there (I forget which - maybe
    Yahoo's?) The xlet could be converted to work on MHP or OCAP without
    much work. This demo is in xlets/demos/weatherWidget, and the project
    is at http://hdcookbook.com, click on the sumo wrestler. It's in the source-code repository,
    but over on the right one of the links will let you browse individual files, which should
    get you pretty quickly to the XML parser in this demo.

    By the way, if you have a choice between JSON and XML in this environment, I'd
    personally go with JSON. It's simpler to parse and faster - indeed, see
    com.hdcookbook.grin.util.JsonIO in the cookbook repository. Of course, if you're
    interacting with a server under your control and you want maximum performance, you
    can use a more efficient binary format, too.

    Cheers,

    Bill
  • 3. Re: converting XML to Java in STB
    843851 Newbie
    Currently Being Moderated
    Hi S@n9,

    I've been using nanoXML-lite before on MHP.
    Light an simple.

    http://devkix.com/nanoxml.php

    Chears,
    Mark
  • 4. Re: converting XML to Java in STB
    843851 Newbie
    Currently Being Moderated
    You could find the answer to your question in this related thread: [http://forums.sun.com/thread.jspa?threadID=5381015|http://forums.sun.com/thread.jspa?threadID=5381015]
  • 5. Re: converting XML to Java in STB
    843851 Newbie
    Currently Being Moderated
    Hi all,
    me too i vote for Json !! it's very easy to deal with and, a lightweight computer data interchange format
         especially if your application have some IPTV features it's highly recommended :)