XML string to Variant

Hi everybody,
I would like to save control values into a database and be able to restore them from it. But I can't set a variant control from an XML string.
This works with flattened string.
Do I make something wrong or is it impossible ?
Attachments:
Test_variant.llb ‏48 KB

Hello,
One workaround for this that is working for me is to use Variant To Flattened String, put the two outputs from that into the XML, and then unflatten out of the XML.  Allows you to store arbitrary datatypes in XML.  I've attached an example screenshot.
Andy
Attachments:
VariantWorkaround.png ‏4 KB

Similar Messages

  • Converting SQL Server text field containing XML string to XI XML via JDBC

    Hello
    My client has a SQL Server database containing a field of type Text which contains an XML string e.g.
    <DispatchJob> <DispatchDateTime>2003-09-29T13:29:15</DispatchDateTime> <AssignedFSE>F118</AssignedFSE> <DispatchJobPurchase> <DealerID>14C5</DealerID> <DateOfPurchase>1997-10-01T00:00:00</DateOfPurchase> </DispatchJob>
    I am using JDBC to access this but could someone please recommend the best and easiest solution for converting this string to XI XML for subsequent mapping to BAPI or IDOC or ABAP Proxy and transmission to SAP. There are other fields as well in the database table so thoughts at the moment are to use a normal graphical message mapping followed by an XSL mapping. Will an XSL mapping be able to do this and if so is that the best solution?
    Also I need to do the reverse of this and take fields coming from SAP via BAPI,IDOC etc. and convert them to a single database table field as an XML string also via the JDBC adapter. What is the best way to do this. Could it be done simply with functions in the graphical mapping e.g. concatenate?
    Thank you in advance.
    Trevor

    Hi Michal
    Thanks for the prompt reply.
    I was anticipating XSLT for reading from the SQL Server database and converting the XML string.
    But how would you convert the individual fields from SAP into a single field as an XML string for storing in the SQL Server database? What approach would you use?
    Regards
    Trevor

  • Performance problem submitting big XML string parameter to the web service

    We deployed a web service on the OC4J via oracle.j2ee.ws.StatelessJavaRpcWebService . This web service takes one string as a parameter. The string contains XML. Evrything works great UNLESS input XML string reaches 5Mb in size. When it happens OC4J does something with it for about 10 minutes (yes, minutes) before it calls the web service method. At this time java.exe consumes 100% of CPU.
    WE tried to increase JVM heap size, stack size, etc, - no effect.
    Please, help!
    Thank you in advance,
    Vlad.

    Hi Sheldon,
    What i feel is that it's not been handled in your webservice if the parameter is null or "" <blank> space
    i just you to take care in webservice that if the parameter is null or "" pass the parameter null to the stored proc
    Regards
    Pavan

  • How can i read XML string in a loop???

    i changed xml file reader to xml string reader by
    looking around this and other forums.
    here is the code.
    public class XMLTester2 {
        public static void main(String[] args) {
            String s = "<firsttag><secondtag>123</secondtag></firsttag>";
            java.io.Reader reader = new java.io.StringReader(s);
            org.xml.sax.InputSource source = new org.xml.sax.InputSource(reader);
            org.w3c.dom.Document doc = null;
            javax.xml.parsers.DocumentBuilderFactory fact = javax.xml.parsers.DocumentBuilderFactory.newInstance();
            try {
                javax.xml.parsers.DocumentBuilder builder = fact.newDocumentBuilder();
                doc = builder.parse(source);
            } catch (javax.xml.parsers.ParserConfigurationException pce) {
            } catch (org.xml.sax.SAXException se) {
            } catch (java.io.IOException ioe) {
            } finally {
                try {
                    reader.close();
                } catch (java.io.IOException ignored) {
    }i put this stuff into a loop, but i always ends up
    having new in the loop.
                String inputLine = "Start";
                // define what's needed for XML messages
                Reader reader = new StringReader(inputLine);
                InputSource source = new InputSource(reader);
                Document doc = null;
                DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
                DocumentBuilder builder = null;
                Node xmlNode = null;
                try {
                    builder = fact.newDocumentBuilder();
                } catch (ParserConfigurationException pce) {
                // -->
                while ( (inputLine = in.readLine()) != null) {
                    System.out.println("readLine() : {" + inputLine + "}");
                    reader = new StringReader(inputLine);
                    source.setCharacterStream(reader);
                    try {
                        doc = builder.parse(source);
                    } catch (SAXException se) {
                        System.out.println("SAXException : " + se);
                        System.out.println("SAXException source : " + source.toString() );
                        se.printStackTrace();
                    } catch (IOException ioe) {
                        System.out.println("IOException : " + ioe);
                    } finally {
                        try {
                            reader.close();
                        } catch (IOException ignored) {
                    reader = null;i know putting new in the loop is VERY bad.
    i gotto get ride of this new from the loop.
    can anyone help me?

    i know putting new in the loop is VERY bad.
    i gotto get ride of this new from the loop.Don't design your application based on one-liners you heard somewhere. Do some timings to see if it matters. My guess would be that parsing an XML file would take a fair bit longer than creating a StringReader object. And you do need a new StringReader each time, they aren't reusable, so the alternatives are not obvious. And don't accept my guess about the timings, check it for yourself.

  • Getting Error while creating Document object  after  parsing XML String

    Hi All,
    I have been trying to parse an XML string using the StringReader and InputSource interface but when I am trying to create Document Object using Parse() method getting error like
    [Fatal Error] :2:6: The processing instruction target matching "[xX][mM][lL]" is not allowed.
    seorg.xml.sax.SAXParseException: The processing instruction target matching "[xX][mM][lL]" is not allowed.
    Please find the code below which i have been experimenting with:
    import java.io.BufferedReader;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.IOException;
    import java.io.StringReader;
    import java.util.List;
    import java.util.*;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    import java.io.*;
    public class TestMain {
         public static void main(String[] args) {
              String file = "";
              file = loadFileContent("C:\\Test.xml");
              System.out.println("contents >> "+file);
              parseQuickLinksFileContent(file);
    public static void parseQuickLinksFileContent(String fileContents) {
    PWMQuickLinksModelVO objPWMQuickLinksModelVO = new PWMQuickLinksModelVO();
         try {
    DocumentBuilderFactory factory =           DocumentBuilderFactory.newInstance();
         DocumentBuilder builder = factory.newDocumentBuilder();
         StringReader objRd = new StringReader(fileContents);
         InputSource objIs = new InputSource(objRd);
         Document document = builder.parse(objIs); // HERE I am getting Error.
         System.out.println(document.toString());
    What is happening while I am using builder.parse() method ???
    Thanks,
    Rajendra.

    Getting following error
    [Fatal Error] :2:6: The processing instruction target matching "[xX][mM][lL]" is not allowed.
    seorg.xml.sax.SAXParseException: The processing instruction target matching "[xX][mM][lL]" is not allowed.

  • Extracting elements from an xml string - org.apache.xerces.dom.DeferredText

    Hello all,
    I am new to xml, and I thought I had a handle on things until I got this problem...I am getting an xml string from the body of an e-mail message, and then I am trying to extract elements out of it. Here is an example xml string:
    <?xml version="1.0" encoding="UTF-8"?>
    <filterRoot>
       <filter action="MOVE" bool="AND" name="My Saved Filter" target="Deleted Items">
          <condition attribute="TO" bool="AND" contains="CONTAINS">
             <value>[email protected]</value>
             <value>[email protected]</value>
             <value>[email protected]</value>
             <value>[email protected]</value>
             <value>[email protected]</value>
          </condition>
       </filter>
    </filterRoot>I am trying to extract the <filter> element out and store it into a Vector of Elements (called, not surprisingly, filters). However, I am getting a class cast exception:
    java.lang.ClassCastException: org.apache.xerces.dom.DeferredTextImplIt is being called from where I trying to extract the <filter> in this way:
            filterRoot = doc.getDocumentElement(); // get topmost element
            NodeList list = filterRoot.getChildNodes();
            Vector newFilters = new Vector();
            debug("There are "+list.getLength()+" filters in document");
            for(int i=0; i<list.getLength(); i++) {
                Node n = list.item(i);
                debug("Node "+i+" getNodeValue() is "+n.getNodeValue());
                Element temp = (Element)n;
                newFilters.add(temp);
            }Perhaps my question is, how do I correctly get hold of the <filter> node so that I may cast it as an Element?
    thanks,
    Riz

    Yes, I already knew that it is not a bug.
    But, I got next step problem.
    I put "false" to "include-ignorable-whitespace" feature in xerces parser.
    But, I still found unnecessary TextNodes in my parser object.
    Feature link : http://xerces.apache.org/xerces-j/features.html.
    I use xerces-2_8_0.
    DOMParser parser = new DOMParser();
    parser.setFeature("http://apache.org/xml/features/dom/include-ignorable-whitespace", false);
    parser.parse(inputSource);
    document = ps.getDocument();
    System.out.println(document.getDocumentElement().getChildNodes().length()); // still wrong lengthIs tehre any example of usage this feature?
    What is default defination of white-space "\n "(enter with one space) or " "(juz white space) or something else?
    Thanks,

  • XML string from Java

    Hi
    I have requirement in which i have a jsp that i use to get information from users. I need to convert the info to XML data into a String , whihc i later use to pass as messages using AQ.
    I also have to, at a later point retreive the data from the XML String, update some information and recreate the XML string object with the new data.
    I do not want to use the XML SQL Utility as this could provide too costly in terms of database hits .
    Is there some XML Parser methods i can use to do the generation and retrieval of XML data into Strings.
    Thanks
    null

    Sort of hack but the way I did it was
    Convert to String:
    Construct a ByteArrayOutputStream
    print your documenet to this,
    and then call the toString() on the
    ByteArrayOutputStream.
    Convert from String to an XMLDocument:
    Construct a StringReader(String s)
    Construct a DOMParser and parse the
    StringReader.
    Hope this helps.
    null

  • How to get an XML string from a Java Bean without wrting to a file first ?

    I know we can save a Java Bean to an XML file with XMLEncoder and then read it back with XMLDecoder.
    But how can I get an XML string of a Java Bean without writing to a file first ?
    For instance :
    My_Class A_Class = new My_Class("a",1,2,"Z", ...);
    String XML_String_Of_The_Class = an XML representation of A_Class ?
    Of course I can save it to a file with XMLEncoder, and read it in using XMLDecoder, then delete the file, I wonder if it is possible to skip all that and get the XML string directly ?
    Frank

    I think so too, but I am trying to send the object to a servlet as shown below, since I don't know how to send an object to a servlet, I can only turn it into a string and reconstruct it back to an object on the server side after receiving it :
    import java.io.*;
    import java.net.*;
    import java.util.*;
    class Servlet_Message        // Send a message to an HTTP servlet. The protocol is a GET or POST request with a URLEncoded string holding the arguments sent as name=value pairs.
      public static int GET=0;
      public static int POST=1;
      private URL servlet;
      // the URL of the servlet to send messages to
      public Servlet_Message(URL servlet) { this.servlet=servlet; }
      public String sendMessage(Properties args) throws IOException { return sendMessage(args,POST); }
      // Send the request. Return the input stream with the response if the request succeeds.
      // @param args the arguments to send to the servlet
      // @param method GET or POST
      // @exception IOException if error sending request
      // @return the response from the servlet to this message
      public String sendMessage(Properties args,int method) throws IOException
        String Input_Line;
        StringBuffer Result_Buf=new StringBuffer();
        // Set this up any way you want -- POST can be used for all calls, but request headers
        // cannot be set in JDK 1.0.2 so the query string still must be used to pass arguments.
        if (method==GET)
          URL url=new URL(servlet.toExternalForm()+"?"+toEncodedString(args));
          BufferedReader in=new BufferedReader(new InputStreamReader(url.openStream()));
          while ((Input_Line=in.readLine()) != null) Result_Buf.append(Input_Line+"\n");
        else     
          URLConnection conn=servlet.openConnection();
          conn.setDoInput(true);
          conn.setDoOutput(true);           
          conn.setUseCaches(false);
          // Work around a Netscape bug
          conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
          // POST the request data (html form encoded)
          DataOutputStream out=new DataOutputStream(conn.getOutputStream());
          if (args!=null && args.size()>0)
            out.writeBytes(toEncodedString(args));
    //        System.out.println("ServletMessage args: "+args);
    //        System.out.println("ServletMessage toEncString args: "+toEncodedString(args));     
          BufferedReader in=new BufferedReader(new InputStreamReader(conn.getInputStream()));
          while ((Input_Line=in.readLine()) != null) Result_Buf.append(Input_Line+"\n");
          out.flush();
          out.close(); // ESSENTIAL for this to work!          
        return Result_Buf.toString();               // Read the POST response data   
      // Encode the arguments in the property set as a URL-encoded string. Multiple name=value pairs are separated by ampersands.
      // @return the URLEncoded string with name=value pairs
      public String toEncodedString(Properties args)
        StringBuffer sb=new StringBuffer();
        if (args!=null)
          String sep="";
          Enumeration names=args.propertyNames();
          while (names.hasMoreElements())
            String name=(String)names.nextElement();
            try { sb.append(sep+URLEncoder.encode(name,"UTF-8")+"="+URLEncoder.encode(args.getProperty(name),"UTF-8")); }
    //        try { sb.append(sep+URLEncoder.encode(name,"UTF-16")+"="+URLEncoder.encode(args.getProperty(name),"UTF-16")); }
            catch (UnsupportedEncodingException e) { System.out.println(e); }
            sep="&";
        return sb.toString();
    }As shown above the servlet need to encode a string.
    Now my question becomes :
    <1> Is it possible to send an object to a servlet, if so how ? And at the receiving end how to get it back to an object ?
    <2> If it can't be done, how can I be sure to encode the string in the right format to send it over to the servlet ?
    Frank

  • How to get XMP MetaData as an XML String in a process?

    Hi there,
    I have a process where I would like to export a documents XMP MetaData, manipulate the XMP MetaData and then import the MetaData again to the document.
    I thougt first I will use the service Name "XMPUtilityService" with the Service Operation "Export XMP" to export the XMP MetaData as a document.
    Hoewer I am not sure how to manipulate the output document from the Export XMP service.
    When I print out the document.toString() in a execute Script Service I get the following:
    <document state="active" senderVersion="0" persistent="false" senderPersistent="false" passivated="false" senderPassivated="false" deserialized="false" senderHostId="null" callbackId="0" senderCallbackId="0" callbackRef="null" isLocalizable="true" isTransactionBound="false" defaultDisposalTimeout="600" disposalTimeout="600" maxInlineSize="65536" defaultMaxInlineSize="65536" inlineSize="3440" contentType="null" length="-1"><cacheId/><localBackendId/><globalBackendId/><senderLocalBackendId/><senderGl obalBackendId/><inline><?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
    <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="A...</inline><senderPullServantJndiName/><attributes/></document>
    Actually I expected something like this:
    <?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
    <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.0-jc006 DEBUG-1.0, 2009 Jun 23 11:07:21-PDT">
       <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
          <rdf:Description rdf:about=""
                xmlns:pdf="http://ns.adobe.com/pdf/1.3/">
             <pdf:Producer>Adobe LiveCycle PDF Generator ES2</pdf:Producer>
          </rdf:Description>
          <rdf:Description rdf:about=""
                xmlns:xmp="http://ns.adobe.com/xap/1.0/">
             <xmp:ModifyDate>2010-04-20T20:43:59+02:00</xmp:ModifyDate>
             <xmp:MetadataDate>2010-04-20T20:43:59+02:00</xmp:MetadataDate>
          </rdf:Description>
          <rdf:Description rdf:about=""
                xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/">
             <xmpMM:DocumentID>uuid:0cf2c6c6-2fba-2b39-5fb6-33ad8ccf58aa</xmpMM:DocumentID>
             <xmpMM:InstanceID>uuid:187bc5a2-acb0-2fa9-711d-33ad8ccf58aa</xmpMM:InstanceID>
          </rdf:Description>
       </rdf:RDF>
    </x:xmpmeta>
    <?xpacket end="w"?>
    What do I need to do to get the XMPMeta data as an XML String from a document within a process?
    Thanks in advance!
    Paul

    Hi,
    thanks for the answer.
    I know that I can retrieve the XMPUtilityMetadata object, but this object provides only access to a few information suche as creator, subject, producer, etc.
    However I would like to retrieve the whole XML String of the XMP Metadata.
    How is this possible?
    Thanks.
    Paul

  • Xml string  to internal table = change  utf-8 to utf-16

    Hello Experts,
    I have a requirement to convert XML String to abap intrnal table .
    I have to get an xml file from application server using opendataset as
    ?<?xml version="1.0" encoding="utf-16" standalone=
    "yes"?><WPUBON01>## <IDOC BEGIN="1">## <EDI_DC
    40 SEGMENT="1">##
    while I am getting as
    <?xml version="1.0" standalone="yes"?>
    <WPUBON01>
    <IDOC BEGIN="1">
    Please advice how I can change the encoding to UTF-16 .
    sun

    Hello Experts,
    I have a requirement to convert XML String to abap intrnal table .
    I have to get an xml file from application server using opendataset as
    ?<?xml version="1.0" encoding="utf-16" standalone=
    "yes"?><WPUBON01>## <IDOC BEGIN="1">## <EDI_DC
    40 SEGMENT="1">##
    while I am getting as
    <?xml version="1.0" standalone="yes"?>
    <WPUBON01>
    <IDOC BEGIN="1">
    Please advice how I can change the encoding to UTF-16 .
    sun

  • XML string to XML parsing in JCD

    I have stored an XML file as a CLOB in the Oracle DB. While fetching this data into JCD using Oracle OTD, I am getting this CLOB field as a string containing the XML. Now I want to parse this XML string to XML, as I need to map the individual fields to an XSD OTD, which will be my output.
    Kindly suggest a way to achieve this.

    An XSD OTD has an unmarshalFromString() method:
    inputFormat.unmarshalFromString( strData );
    When putting the XML into the CLOB it could be a good idea to wrap an outputstream into a Writer object in order to make certain that the encoding is correct, depending how the data is represented. When retrieving CLOB data using getCharacterStream() you will get a Reader object where the encoding is already given.

  • Conversion of xml string to xml file

    To convert xml string to xml file in java i used
    Document XMLDoc=DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader("<root><main>Title</main></root&g t;")));
    But it is showing an error as InputSource cannot be resolved
    How to rectify this

    I assume you mean there is a compiler error? (It helps if you explain your problem instead of just giving a vague description of it.) It sounds like you have to import InputSource. You do know about the import statements that go at the beginning of a Java class, don't you?

  • XML : Transform DOM Tree to XML String in an applet since the JRE 1.4.2_05

    Hello,
    I build a DOM tree in my applet.
    Then I transform it to XML String.
    But since the JRE 1.4.2_05 it doesn't work.
    These lines failed because these variables became final:
    org.apache.xalan.serialize.CharInfo.XML_ENTITIES_RESOURCE = getClass().getResource("XMLEntities.res").toString();
    org.apache.xalan.processor.TransformerFactoryImpl.XSLT_PROPERTIES = getClass().getResource("XSLTInfo.properties").toString();The rest of the code :
    DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = domFactory.newDocumentBuilder();
    Document domXML = builder.newDocument();
    // I build my DOM Tree
    StringWriter xmlResult = new StringWriter();
    Source source = new DOMSource(domXML);
    Result result = new StreamResult(xmlResult);
    Transformer xformer = TransformerFactory.newInstance().newTransformer();
    xformer.setOutputProperty(javax.xml.transform.OutputKeys.INDENT,"yes");
    xformer.transform(source,result);Is there any other way to get an XML String from a DOM tree in an applet ?
    I'm so disappointed to note this big problem.

    Does anyone have an idea why I get this error message when try to use transform in an applet?
    Thanks...
    java.lang.ExceptionInInitializerError
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Unknown Source)
         at org.apache.xalan.serialize.SerializerFactory.getSerializer(Unknown Source)
         at org.apache.xalan.transformer.TransformerIdentityImpl.createResultContentHandler(Unknown Source)
         at org.apache.xalan.transformer.TransformerIdentityImpl.transform(Unknown Source)
         at matrix.CreateMtrx.SaveDoc(CreateMtrx.java:434)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at thinlet.Thinlet.invokeImpl(Unknown Source)
         at thinlet.Thinlet.invoke(Unknown Source)
         at thinlet.Thinlet.handleMouseEvent(Unknown Source)
         at thinlet.Thinlet.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)
    Caused by: java.lang.RuntimeException: The resource [ XMLEntities.res ] could not load: java.net.MalformedURLException: no protocol: XMLEntities.res
    XMLEntities.res      java.net.MalformedURLException: no protocol: XMLEntities.res
         at org.apache.xalan.serialize.CharInfo.<init>(Unknown Source)
         at org.apache.xalan.serialize.SerializerToXML.<clinit>(Unknown Source)
         ... 28 more

  • How to parse XML string fetched from the database

    i want to parse the XML string which is fetched from the oracle database.
    i have inserted the string in xml format in the database. The type of the field in which it is inserted is varchart2.
    I am successfully getting it using jdbc, storing it in a String.
    Now it is appended with xml version 1.0 and string is ready for parsing.
    Now i am making following programming.
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document doc = Builder.parse(xmlString);
    Element root = doc.getDocumentElement();
    NodeList node = root.getElementsByTagName("product");
    But i am getting IOException at the statement
    Document doc = Builder.parse(xmlString);
    there fore i request u to kindly help me in solving this error.
    -regards
    pujan

    DocumentBuilder does not have a method parse with xml string as aparameter. The string should be a xml document uri.
    Convert xml string to StringReader.
    parse(new InputSource(new StringReader(xmlString)));

  • Parse an XML String

    hi lets say i got an XML String which looks like this..
    String xmlstring = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><GET_REALIZED_GAIN_LOSS_DETAIL_RESPONSE xsi:schemaLocation=\"http://www.statementone.com/webservice/schemas D:\\PMTSchema.xsd\" xmlns=\"http://www.statementone.com/webservice/schemas\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><STATUS>true</STATUS><ERRORS><ERROR><TYPE>String</TYPE><MESSAGE>String</MESSAGE><ERROR_ID>1</ERROR_ID></ERROR><ERROR><TYPE>String</TYPE><MESSAGE>String</MESSAGE><ERROR_ID>1</ERROR_ID></ERROR></ERRORS><GET_REALIZED_GAIN_LOSS_RESULT><XYZ>String</XYZ></GET_REALIZED_GAIN_LOSS_RESULT></GET_REALIZED_GAIN_LOSS_DETAIL_RESPONSE>";
    DocumentBuilderFactory factory =
    DocumentBuilderFactory.newInstance();
    DocumentBuilder db = factory.newDocumentBuilder();
    InputSource inStream = new InputSource();
    inStream.setCharacterStream(new StringReader(xmlstring));
    Document doc1 = db.parse(inStream);
    I notice that all the values i set in XML are available in the doc1 field. But I was not able to get them as a string..
    Can Some one tell me how to get the attributes out of the doc1? I tried getElementBytag and other options.. Do i need to take out the tag items in the sequence in which they are given? or can i select a tag random and pick up the attributes??
    Plzz help me out!!

    Hope this helps you, let me know.
    String xmlstring = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>.......  </GET_REALIZED_GAIN_LOSS_DETAIL_RESPONSE>";
         DocumentBuilderFactory factory =
         DocumentBuilderFactory.newInstance();
         DocumentBuilder db = factory.newDocumentBuilder();
         InputSource inStream = new InputSource();
         inStream.setCharacterStream(new StringReader(xmlstring));
         Document doc1 = db.parse(inStream);
       NamedNodeMap attribes = doc1.getAttributes();
       NodeList nodes = doc1.getChildNodes();http://snippets.dzone.com/posts/show/3575
    http://www.brics.dk/~amoeller/XML/programming/domexample.html
    Message was edited by:
    Srini_Kandula

Maybe you are looking for