Results 1 to 6 of 6

Thread: Xml

  1. #1
    tmotse is offline Member
    Join Date
    Mar 2010
    Posts
    17
    Rep Power
    0

    Default Xml

    Hi Guys
    I have an XML which i want to convert to a Document:
    Here is my XML: Can someone direct me to a link or give a hint of how to do it:

    Java Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservices.server.vit.za.mfgad.com/">
       <soapenv:Header/>
       <soapenv:Body>
          <web:newOutboundVoiceRouteRequest>
             <!--Optional:-->
             <requestDetail>
                <!--Optional:-->
                <assignedUser>?</assignedUser>
                <!--Optional:-->
                <externalCorrIdentifier>?</externalCorrIdentifier>
                <!--Optional:-->
                <externalIdentifier>?</externalIdentifier>
                <!--Optional:-->
                <interactionSource>?</interactionSource>
                <!--Optional:-->
                <mediaChannelRouteIdentifier>?</mediaChannelRouteIdentifier>
                <!--Zero or more repetitions:-->
                <dialNumbers>?</dialNumbers>
                <!--Optional:-->
                <displayInformation>?</displayInformation>
                <!--Optional:-->
                <externalPartyIdentifier>?</externalPartyIdentifier>
                <!--Optional:-->
                <externalPartyName>?</externalPartyName>
             </requestDetail>
          </web:newOutboundVoiceRouteRequest>
       </soapenv:Body>
    </soapenv:Envelope>

    Thank you:
    Thuto(South Africa)

    Moderator edit: code tags added
    Last edited by Fubarable; 06-29-2010 at 03:04 PM. Reason: Moderator edit: code tags added

  2. #2
    tolja is offline Member
    Join Date
    Jun 2010
    Posts
    4
    Rep Power
    0

    Default here is the example xml to documnet parser


  3. #3
    svidurs1 is offline Member
    Join Date
    Mar 2010
    Posts
    9
    Rep Power
    0

    Default

    @tolja, That was a great help ..

    Can somebody please help me with something similiar ?
    I have to read xml file using jxl and dump its contents to an excel file (again using jxl).
    writing contents to excel file is straight-forward. I am struck with readin xml contents using jxl.
    its urgent !! I am in need of it before end of today,

  4. #4
    mangstadt is offline Member
    Join Date
    Jul 2010
    Location
    USA
    Posts
    19
    Rep Power
    0

    Default

    Java Code:
    String xml = //...
    StreamSource source = new StreamSource(new StringReader(xml));
    DOMResult result = new DOMResult();
    Transformer transformer = TransformerFactory.newInstance().newTransformer();
    transformer.transform(source, result);
    Document root = (Document)result.getNode();
    Last edited by mangstadt; 07-01-2010 at 03:27 PM.

  5. #5
    svidurs1 is offline Member
    Join Date
    Mar 2010
    Posts
    9
    Rep Power
    0

    Default

    @mangstadt,
    thanx for help.. but i m getting null for my root.

  6. #6
    mangstadt is offline Member
    Join Date
    Jul 2010
    Location
    USA
    Posts
    19
    Rep Power
    0

    Default

    There was a mistake in my code sample. See my prev post for the updated code.

    What are you doing to test for it being null? The following is normal output for System.out.println(root);

    [#document: null]

    This doesn't mean the document is null. To get the root XML element, call root.getFirstChild();

    How do you like the World Cup? ;)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •