Transform XML-String to human readable XML-File

I need to transform a XML-String as coming from a simple transformation into a human readable XML-File. That means with linebreaks and logical indenting, each line not longer than n charactors.
Example:
<one><two>text</two><three><four>text</four></three></one>
into
<one>
  <two>text</two>
  <three>
    <four>text</four>
  </three>
</one>

I wrote a method that will do this, but the method can not handle all kinds of XML-strings, but it works with most simple XML-Strings:
METHOD xml_str2table.
*** Importing
**    I_XMLSTRING type csequence
*** Returning
***   e_tab_XMLtab type table of string.        
  DATA l_cnt_length TYPE i.
  l_cnt_length = STRLEN( i_xmlstring ).
  DATA l_cnt_index TYPE i.
  DATA l_xmlline TYPE string.
  DATA l_oldchar TYPE c.
  DATA l_char TYPE c.
  DATA l_nextchar TYPE c.
  DATA l_indent TYPE i.
  DO l_cnt_length TIMES.
    l_cnt_index = sy-index - 1.
    l_char = i_xmlstring+l_cnt_index(1).
    IF sy-index < l_cnt_length.
      l_nextchar = i_xmlstring+sy-index(1).
    ENDIF.
    IF  l_char <> cl_abap_char_utilities=>newline.
      IF ( l_char = '<' AND l_nextchar = '/' ) OR
         ( l_char = '/' AND l_nextchar = '>' ).
        l_indent = l_indent - 1.
        IF l_indent < 0.
          l_indent = 0.
        ENDIF.
      ENDIF.
      IF l_char = '<' AND l_oldchar = '>'.
        APPEND l_xmlline TO e_tab_xmltab.
*      write: / l_xmlline.
        CLEAR l_xmlline.
        DO l_indent TIMES.
          CONCATENATE space space l_xmlline INTO l_xmlline SEPARATED BY space.
        ENDDO.
      ENDIF.
      if l_char <> space.
        CONCATENATE l_xmlline l_char INTO l_xmlline.
      else.
        CONCATENATE l_xmlline l_char INTO l_xmlline SEPARATED BY space.
      endif.
      IF l_char = '<' AND l_nextchar <> '/'.
        l_indent = l_indent + 1.
      ENDIF.
    ELSE.
      l_indent = 0.
      APPEND l_xmlline TO e_tab_xmltab.
*    write: / l_xmlline.
      CLEAR l_xmlline.
    ENDIF.
    l_oldchar = l_char.
  ENDDO.
  APPEND l_xmlline TO e_tab_xmltab.
*write: / l_xmlline.
ENDMETHOD.
The second Method does the same not with an string, but with an X-String:
METHOD xml_xstr2table.
*** Importing
**    I_XMLSTRING type xsequence
*** Returning
***   e_tab_XMLtab type table of string.     
  DATA l_tmp_string TYPE string.
  DATA conv TYPE REF TO cl_abap_conv_in_ce.
  conv = cl_abap_conv_in_ce=>create(
            encoding = 'UTF-8'
            endian = 'L' ).
  conv->convert(
    EXPORTING input = i_xmlstring
    IMPORTING data = l_tmp_string ).
  e_tab_xmltab = xml_str2table( l_tmp_string ).
ENDMETHOD.

Similar Messages

  • REG: WRITE XML STRING INTO XML FILE

    Hi All, I have a XML FILE on PC. I get a xml string from my server.
    My Task: I want to append the xml string coming from the server into the existing xml file at a particular Node. Given below is my code :
    String xmlString = baos.toString();
                      DocumentBuilder db4XMLString = docBuilderFactory.newDocumentBuilder();
                      InputSource inStream = new InputSource();
                      inStream.setCharacterStream(new StringReader(xmlString));
                      Document doc4XMLString = db4XMLString.parse(inStream);
                      Node root4XMLString = doc4XMLString.getElementsByTagName("epg").item(0);
                      doc.appendChild(doc.importNode(root4XMLString, true));
                      File file = new File(Constant.XMLFILEPATH);
                      Result result = new StreamResult(file.toURI().getPath());
                      Source source = new DOMSource(doc);
                      Transformer xformer = TransformerFactory.newInstance().newTransformer();
                      xformer.transform(source, result);But, wen i run my application I get following exception:
    The markup in the document following the root element must be well-formed.
    org.xml.sax.SAXParseException: The markup in the document following the root element must be well-formed.
    at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    Is that my XML string is not well formed. Is it so then please let me how to convert my xml string into well formed XML data.
    Please help me out.
    Thanking You.

    There are many reasons why xmlString could be not well formed. There is no magic recipe for making it well formed: just look at it and see why it is not parseable.
    Note that this line:
    String xmlString = baos.toString();can be problematic if you have non ASCII-7 characters in your XML document. baos could then contain a byte representation of these characters in one particular encoding, but, since you use the .toString() method that relies on the default encoding of your system, you can end up with a mismatch and garbage in your XML.

  • How to Parse an XML string

    I need some help to parse an XML String instead of an XML file. The string can be like.
    String myRecords =
    "<data>"+
    " <employee>"+
    " <name>John</name>"+
    " <Designation>Manager</Designation>"+
    " </employee>"+
    " <employee>"+
    " <name>Sara</name>"+
    " <Designation>Clerk</Designation>"+
    " </employee>"+
    "<data>"+

    I tried it in a servlet, it and it worked. The entire code is long. But here it is most of it:
    assuming that x is a string and has the xml of
    <?xml version="1.0" ?>
    - <company>
    - <employee>
    <firstname>Tom</firstname>
    <lastname>Cat</lastname>
    </employee>
    - <employee>
    <firstname>Paul</firstname>
    <lastname>Enderson</lastname>
    </employee>
    - <employee>
    <firstname>George</firstname>
    <lastname>Jungle</lastname>
    </employee>
    </company>
    =========================
    try {
    DocumentBuilderFactory factory =
    DocumentBuilderFactory.newInstance();
    DocumentBuilder db = factory.newDocumentBuilder();
    InputSource inStream = new InputSource();
    inStream.setCharacterStream(new StringReader(*x*));
    Document doc = db.parse(inStream);
    doc.getDocumentElement().normalize();
    out.println("Root element " + doc.getDocumentElement().getNodeName() + "<BR>");
    NodeList nodeLst = doc.getElementsByTagName("employee");
    out.println("Information of all employees<BR>");
    for (int s = 0; s < nodeLst.getLength(); s++) {
    Node fstNode = nodeLst.item(s);
    if (fstNode.getNodeType() == Node.ELEMENT_NODE) {
    Element fstElmnt = (Element) fstNode;
    NodeList fstNmElmntLst = fstElmnt.getElementsByTagName("firstname");
    Element fstNmElmnt = (Element) fstNmElmntLst.item(0);
    NodeList fstNm = fstNmElmnt.getChildNodes();
    out.println("First Name : " + ((Node) fstNm.item(0)).getNodeValue() + "<BR>");
    NodeList lstNmElmntLst = fstElmnt.getElementsByTagName("lastname");
    Element lstNmElmnt = (Element) lstNmElmntLst.item(0);
    NodeList lstNm = lstNmElmnt.getChildNodes();
    out.println("Last Name : " + ((Node) lstNm.item(0)).getNodeValue() + "<BR>");
    } catch (Exception e) {
    System.out.println(e);
    out.close();
    ==============
    The output is
    Root element company
    Information of all employees
    First Name : Tom
    Last Name : Cat
    First Name : Paul
    Last Name : Enderson
    First Name : George
    Last Name : Jungle

  • Xml string passed as parameter to xsql

    I am trying to pass xml string as parameter to xsql.But having problems with the < and > .I tried to escape
    those chars but but i am not getting desired output.Could you please suggest how to pass the xml string .
    <xsql:include-xsql href="order.xsql?neworder='{@neworder}'
    i trying to pass neworder parameter as xml string which contains data to update 2-3 table .

    u can't post a parameter valued by a xml string,because of the xml string must be
    has xml element with attributes. as follows:
    <row num="1">
    the "=" will make the web container got error
    when parsing http request parameters's name and value pair.
    solution:
    1. use "post" method submit your parameter
    2. use microsoft xml http compoment post your param as a parameter
    of it's "send" method, and set the request contentType header "text/xml"
    in xsql file:
    <xsql:set-page-param name="param1" xpath="/parameters/neworder"/>
    try it :->

  • Print content of XML string to a spool

    Hello,
    In my program I have an XML string. I can display this on the screen using FM DISPLAY_XML_STRING.
    The problem is that when running the program in background, it does not generate a spool.
    Is there a standard way (function module or class) which parses the XML string and prints the xml document to the spool?
    Kind Regards
    Koen Van Loocke

    Hi
    Try using this FM: CRM_IC_XML_XSTRING2STRING. It will give XML string when you specify byte string.
    Then you can display the same using WRITE statement.

  • Does anyone can help me to import XML string into a ORACLE database

    Hi guys!
    i have some problem that my friend wants me to convert XML string to Oracle relational database which means.
    let's say, there is a table that a row has XML string.
    so table has XML string with varchar type.
    what my friend want me to do is, the string needs to be solved as a relational database.
    like
    A table has 'ID', 'data', 'result' rows
    and Data column has XML string like <?xml version...............>
    then wants to convert that data column's XML data into TABLE B with structure normally XML has.
    i'm so confused and have no idea at all.. also i couldn't find any solution related to my stuff..
    if someone knows how to solve the problem, just let us know
    thx

    The database is 10.2.0
    What sort of example do u want me to give you..
    i thought i give all information on the post..
    i will explain it
    let's say there are 3 columns ID,Name,Code
    Id = normal integer
    Name= varchar
    Code= varchar
    and i need to conver that XML in the Code column into relational databases
    the code column has normal XML code which is starting from <?xml version.... and so on
    so does it explain?
    please help me!

  • Parsing XML Strings

    I am getting an XML String from a web-service.. Is there a method inside of BPM to parse this xml string?

    Hi, my xml string is:-
    <?xml version="1.0" encoding="UTF-8" ?>
    <ns2:Exception xmlns:ns2="http://example.com/" >
         <errorCode>0</errorCode>
         <errorSubcode>0</errorSubcode>
         <message>Connection refused</message>
         <messageWithProperties>Connection refused
         Error Code=[0]
         ticketId=[1]
         fileName=[testFile]
    </messageWithProperties>
         <properties>
              <name>Error Code</name>
              <value>0</value>
         </properties>
         <properties>
              <name>ticketId</name>
              <value>1</value>
         </properties>
         <properties>
              <name>fileName</name>
              <value>testFile</value>
         </properties>
         <propertiesAsString>     Error Code=[0]
         ticketId=[1]
         fileName=[testFile]
    </propertiesAsString>
    </ns2:Exception>
    I wanted to parse through it and get the errorCode....
    I am using :-
    xmlObject.load(xmlText : xmlContent);
    xmlMessage = xmlObject.selectString(xpath : "/ns2/errorCode");
    But this doesn't seem to work..
    Any idea?

  • Update xml string values.

    Hi,
    I'm on 11.2.0.2 and got table with nclob column which stores long xml string .
    {code}
    "<?xml version="1.0" encoding="UTF-8"?>
    <?fuego version="6.5.2" build="101272"?>
    <set>
    <configuration name="TEST Database" type="SQL" subtype="DDORACLE">
      <property name="jdbc.pool.idle_timeout" value="5"/>
      <property name="jdbc.pool.entry.max" value="10"/>
      <property name="oracle.dateEqualsTimestamp" value="false"/>
      <property name="jdbc.schema" value="user1"/>
      <property name="jdbc.host" value="hostname"/>
      <property name="user" value="user1"/>
      <property name="jdbc.port" value="1521"/>
      <property name="jdbc.pool.min" value="0"/>
      <property name="jdbc.pool.maxopencursors" value="50"/>
      <property name="oracle.sid" value="dbsid"/>
      <property name="password" value="user101"/>
      <property name="jdbc.xa" value="false"/>
      <property name="jdbc.pool.max" value="10"/>
    </configuration>
    <configuration name="TEST Database2" type="SQL" subtype="DDORACLE">
      <property name="jdbc.pool.idle_timeout" value="5"/>
      <property name="jdbc.pool.entry.max" value="10"/>
      <property name="oracle.dateEqualsTimestamp" value="false"/>
      <property name="jdbc.schema" value="user2"/>
      <property name="jdbc.host" value="hostname"/>
      <property name="user" value="user2"/>
      <property name="jdbc.port" value="1521"/>
      <property name="jdbc.pool.min" value="0"/>
      <property name="jdbc.pool.maxopencursors" value="50"/>
      <property name="oracle.sid" value="dbsid2"/>
      <property name="password" value="user201"/>
      <property name="jdbc.xa" value="false"/>
      <property name="jdbc.pool.max" value="10"/>
    </configuration>
    </set>
    {code}
    My goal is to update password value in such way that it equals to value from jdbc.schema value  <property name="jdbc.schema" value="user2"/>   so in this case user2 || '01'
    <property name="password" value="user201"/>   <-- that is my goal .
    Regards
    Greg

    Hi,
    You can find a few methods here : How To : Update XML nodes with values from the same document | Odie's Oracle Blog
    They're not all applicable to your version and settings though.
    Here's the first one applied to your case :
    declare
      v_xmldoc   xmltype;
    begin
      select xmlparse(document to_clob(t.xmldoc))
      into v_xmldoc
      from my_nclob_table t
      where t.id = 1;
      for r in (
        select idx, schema_name
        from my_nclob_table t
           , xmltable(
               '/set/configuration'
               passing v_xmldoc
               columns idx         for ordinality
                     , schema_name varchar2(30) path 'property[@name="jdbc.schema"]/@value'
      loop
        select updatexml(
                 v_xmldoc
               , '/set/configuration['||to_char(r.idx)||']/property[@name="password"]/@value'
               , r.schema_name || '01'
        into v_xmldoc
        from dual ;
      end loop;
      update my_nclob_table t
      set t.xmldoc = to_nclob(xmlserialize(document v_xmldoc indent))
      where t.id = 1;
    end;
    Here's another one, using DOM :
    declare
      doc   clob;
      p        dbms_xmlparser.Parser;
      domdoc   dbms_xmldom.DOMDocument;
      docnode  dbms_xmldom.DOMNode;
      conf_list      dbms_xmldom.DOMNodeList;
      conf_node      dbms_xmldom.DOMNode;
      password_node  dbms_xmldom.DOMNode;
      schema_name     varchar2(30);
      password_value  varchar2(256);
    begin
      select to_clob(xmldoc)
      into doc
      from my_nclob_table
      where id = 1 ;
      p := dbms_xmlparser.newParser;
      dbms_xmlparser.parseClob(p, doc);
      domdoc := dbms_xmlparser.getDocument(p);
      dbms_xmlparser.freeParser(p);
      docnode := dbms_xmldom.makeNode(domdoc);
      conf_list := dbms_xslprocessor.selectNodes(docnode, '/set/configuration');
      for i in 0 .. dbms_xmldom.getLength(conf_list) - 1 loop
        conf_node := dbms_xmldom.item(conf_list, i);
        dbms_xslprocessor.valueOf(conf_node, 'property[@name="jdbc.schema"]/@value', schema_name);
        password_node := dbms_xslprocessor.selectSingleNode(conf_node, 'property[@name="password"]/@value');
        dbms_xmldom.setNodeValue(password_node, schema_name || '01');
      end loop;
      dbms_xmldom.writeToClob(domdoc, doc);
      dbms_xmldom.freeDocument(domdoc);
      update my_nclob_table t
      set t.xmldoc = to_nclob(doc)
      where t.id = 1;
    end;
    Message was edited by: odie_63 - added DOM example

  • Generating XML String

    I may have missed something obvious but the SAX & DOM bits of
    the XML Parser don't seem to supply any way of getting from a
    set of parsed (or created) Document Java objects to a marked up
    XML string. Is this something we have to do ourselves by
    navigating through the node tree and adding the necessary
    markup? It seems generic enough to be provided by one of your
    APIs (such as the XSL bits?).
    Thanks,
    Dave
    null

    Thanks,
    I found the print method on the XMLDocument class which
    generates an encoded string from that XMLDocument. This is fine
    but what I had was a DocumentFragment reference returned from
    the XSLProcessor.
    I assume you have to get an XMLDocument from this
    DocumentFragment (since XMLDocument doesnt implement that
    interface) by creating an empty XMLDocument and then appending
    the DocumentFragment as a child element. You can then use the
    print method to get the XML string containing the styled XML.
    This seems to work ok. Is this the right way to go about it?
    Cheers,
    Dave
    Oracle XML Team wrote:
    : In oracle.xml.parser.NodeFactory you will find a
    createDocument
    : method which will create the document node to get your XML
    : document starter. This method was omitted in the DOM Level 1
    : Req but has been added for Level 2. We have implemented it in
    : both our v1 and v2 parsers.
    : Oracle XML Team
    : http://technet.oracle.com
    : Oracle Technology Network
    : Dave Barton (guest) wrote:
    : : I may have missed something obvious but the SAX & DOM bits
    of
    : : the XML Parser don't seem to supply any way of getting from
    a
    : : set of parsed (or created) Document Java objects to a marked
    : up
    : : XML string. Is this something we have to do ourselves by
    : : navigating through the node tree and adding the necessary
    : : markup? It seems generic enough to be provided by one of
    your
    : : APIs (such as the XSL bits?).
    : : Thanks,
    : : Dave
    null

  • Web Services Consumer Transformation does not expand xml string in WSDL

    I am trying to create a WebService Consumer transformation with a WSDL file which I have imported in Informatica PowerCenter.The WSDL file has complexType xml strings which are not getting expanded while I am importing the WSDL file, thus it’s not showing the input and output fields in the request and response respectively. I have xsd file definition for these xml strings separately and there is no way I can incorporate them with the main WSDL in PowerCenter.  While I looked into the Informatica Documentation I found that in the Developer tool I can create Web Service in Data Services, and incorporate xsd element definition with main WSDL file. But it’s not exactly working in the way its described in the documentation. Any help would be appreciated.

    Hello All, I have got a scenario to implement: I have a Character source column which I need to convert to Numeric(18,4) and load into table. My source and target is a Netezza table. If the conversion fails, we do not drop the record, instead insert NULL for those records,i.e. source and target has same number of records. I use an expression as below : DECODE(Input_String, NULL, NULL-- Check for alphabets IIF((UPPER(Input_String) != LOWER(Input_String)), NULL-- Check for special charactersIIF((INSTR(Input_String,',',1) > 0 || INSTR(Input_String,':',1) > 0 || INSTR(Input_String,'@',1) > 0),NULL, TO_DECIMAL(Input_String,4))    )       ) Now my question is, can we use a single INSTR statement and check for all the special characters? I want to avoid writing multiple INSTR statements. Please suggest me how to check multiple characters in a single INSTR statement. Thanks & RegardsBiswajeet.

  • How to convert  information of a job posting into a xml string or file

    hi hr experts,
    I hope to find some answers.
    Is there a function in the ERP system that converts all the information of a job posting into a xml string or file?
    This could be used to communicate with external job databases, e.g. monster or jobpilot.
    The function CALL TRANSFORMATION converts data to XML. Is this really the only way to convert the job posting?
    Thanks for your feedback and help.
    Ralf von Seht
    Edited by: Ralf von Seht on Mar 26, 2008 4:45 PM
    Edited by: Ralf von Seht on Mar 26, 2008 4:46 PM

    Hi Elena,
    The issue is caused by XSLT is not script enabled by default.  Please provide XsltSettings in the loading to fix the issue. For more information, please see:
    http://daomingworks.wordpress.com/2009/12/11/xslt-transform-data-error-use-the-xsltsettings-enablescript-property-to-enable-it/
    Thanks,
    Jinchun Chen
    Jinchun Chen
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff AT microsoft.com(Please replace AT with @)

  • Insert XML String into XML file at a certain position

    Hello,
    I have this xml string:
    <jdbc-driver-params>
    <url>jdbc:oracle:thin:@localhost:1521:mydb</url>
    <driver-name>oracle.jdbc.OracleDriver</driver-name>
    <properties>
    <property>
    <name>user</name>
    <value>myuser</value>
    </property>
    </properties>
    <password-encrypted>myuser</password-encrypted>
    </jdbc-driver-params>and i need to insert it into an xml file at a certain position (as child for a node)
    The xml file looks like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <jdbc-data-source xmlns="http://www.bea.com/ns/weblogic/90"
        xmlns:sec="http://www.bea.com/ns/weblogic/90/security"
        xmlns:wls="http://www.bea.com/ns/weblogic/90/security/wls"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/920 http://www.bea.com/ns/weblogic/920.xsd">
        <name>myDB</name>
        <jdbc-data-source-params>
            <global-transactions-protocol>OnePhaseCommit</global-transactions-protocol>
        </jdbc-data-source-params>
    </jdbc-data-source>And this is how I would like to get it in the end:
    <?xml version='1.0' encoding='UTF-8'?>
    <jdbc-data-source xmlns="http://www.bea.com/ns/weblogic/90" xmlns:sec="http://www.bea.com/ns/weblogic/90/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wls="http://www.bea.com/ns/weblogic/90/security/wls" xsi:schemaLocation="http://www.bea.com/ns/weblogic/920 http://www.bea.com/ns/weblogic/920.xsd">
      <name>mydb</name>
      <jdbc-driver-params>
        <url>jdbc:oracle:thin:@localhost:1521:myDB</url>
        <driver-name>oracle.jdbc.OracleDriver</driver-name>
        <properties>
          <property>
            <name>user</name>
            <value>myuser</value>
          </property>
        </properties>
        <password-encrypted>myuser</password-encrypted>
      </jdbc-driver-params>
      <jdbc-connection-pool-params>
        <test-table-name>SQL SELECT 1 FROM DUAL</test-table-name>
      </jdbc-connection-pool-params>
      <jdbc-data-source-params>
        <global-transactions-protocol>OnePhaseCommit</global-transactions-protocol>
      </jdbc-data-source-params>
    </jdbc-data-source>So, I obtain the node for the given xml string, the jdbc-data-source node from the xml file and i attempt the appendChild. The problem is that nothing really gets inserted into the xml file.
    Someone, any idea?
    My code:
    try
                   DOMParser parser = new DOMParser();
                   parser.parse(xmlFileName);
                   Document doc = parser.getDocument(); // the document we will insert node into
                   Node root = doc.getElementsByTagName("jdbc-data-source").item(0);
                   //get XML string node
                   DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                   DocumentBuilder db = factory.newDocumentBuilder();
                   InputSource inStream = new InputSource();
                   inStream.setCharacterStream(new StringReader(xmlString));
                   Document doc4XMLString = db.parse(inStream);
                   Node rootXMLString = doc4XMLString.getElementsByTagName("jdbc-driver-params").item(0);
                   root.appendChild(doc.importNode(rootXMLString, true));
                   return true;
              catch (Exception e)
                   e.printStackTrace();
              }Thanks,
    johnny
    Edited by: smeag0l on Aug 6, 2008 5:08 PM
    Edited by: smeag0l on Aug 6, 2008 5:43 PM

    Well, you helped me again :-) Thank you very much!
    Here is how the code should look:
                            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                   DocumentBuilder db4XMLFile = factory.newDocumentBuilder();
                   Document doc4XMLFile = db4XMLFile.parse(xmlFileName);
                   Node root4XMLFile = doc4XMLFile.getElementsByTagName(rootNodeName).item(0);
                   DocumentBuilder db4XMLString = factory.newDocumentBuilder();
                   InputSource inStream = new InputSource();
                   inStream.setCharacterStream(new StringReader(xmlString));
                   Document doc4XMLString = db4XMLString.parse(inStream);
                   Node root4XMLString = doc4XMLString.getElementsByTagName(xmlStringNodeName).item(0);
                   root4XMLFile.appendChild(doc4XMLFile.importNode(root4XMLString, true));
                   File file = new File(xmlFileName);
                            Result result = new StreamResult(file.toURI().getPath());
                   Source source = new DOMSource(doc4XMLFile);
                   Transformer xformer = TransformerFactory.newInstance().newTransformer();
                      xformer.transform(source, result);

  • Howto transform a Sales Order (idoc) into xml file and download it?

    I need to tranform a Sales order into an xml file such that I could download the file onto my disk. I try to transform an IDOC.
    I do the following from an example and I get an xml document on screen but I do get get any file downloaded:
    DATA: document TYPE REF TO if_ixml_document.
      document = g_ixml->create_document( ).
      DATA: ostream TYPE REF TO if_ixml_ostream.
    ostream = g_stream_factory->create_ostream_uri(
      system_id = 'file://C:\test.xml' ).
      DATA: renderer TYPE REF TO if_ixml_renderer, rc TYPE i.
    renderer = g_ixml->create_renderer( ostream  = ostream
                                          document = document ).
      rc = renderer->render( ).
      document->render( ostream = ostream  recursive = ' ').
    Is there something else I should do? Is there another approach for transforming a sales order to an xml file.
    The R/3 4.6 system is used.
    Thank you
    -eglese-

    Hi Eglese,
    Another option could be to use XML port configured for the IDOC and use the XML files generated be extracted from Web Dynpro using a file download UI element.
    Thanks and Regards,
    Sam Mathew

  • 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 use an .xsl file to transform input XML to re-formatted output XML?

    Hello,
    I have a .xml file from a report that I want to use a stylesheet to transform into a different .xml format.
    I am reading that I can create a .xsl file to read my input and then transform it to a new output .xml file.
    How do I load this into the Apps?
    I tried creating a template definition and loading the .xsl in as type 'XSL-TEXT' and also, I added
    <?xml-stylesheet type="text/xsl" href="Transform.xsl"?> to my xml data source. The output looked the same as the input.
    Has anyone done this before? Any suggestions would be great!
    Thanks
    -CC

    This is how I use e4x with HTTPService:
    import mx.collections.XMLListCollection;
    import mx.rpc.events.ResultEvent;
    [Bindable] private var claimsXLC:XMLListCollection;
    private function claimsHandler(evt:ResultEvent):void{
        claimsXLC = new XMLListCollection(evt.result..claim as XMLList);
    XML data is being returned, but I use XMLList to create the XMLListCollection.
    If this post answers your question or helps, please mark it as such.

Maybe you are looking for

  • Settings still don't retain.

    So, it's 3.0.3 already but one of the most importal features still doesn't work. Seriously, how hard can it be to fix it?

  • Exception Side-loading Metro application to Windows 8.1 Pro tablet

    I'm running a Windows 8.1 Pro system in a tablet, I side-loaded a metro application developed with VS 2013 for testing purpose. I was able to do it one time, and everything worked fine, but when the I tried to side-load an update for my application I

  • LR Web Module color management problem

    I stumbled on to this discussion thread: http://forums.adobe.com/message/3572174#3572174 initiated by "JimmysPhoto" because I have observed the same LR Web Module problem with images too saturated too much contrast and clipped highlights & shadows. P

  • Outgoing calls doesn't display DID number?

    hi all, Q1.) With refer to belows, I hope the "Calling Party Number i = 0x0081, '33800' " should appear '8883800' ? Q2.) I hope my mobilephone will display 8883800 instead of just the extension number 33800 as you seen belows. Any idea how to do that

  • Lost GlassFish admin password# how to reset admin password

    Hi i lost admin password in glassfish(     GlassFish Server Open Source Edition 3.1.1 (build 12) ) application server key-file stored in glassfish-3.1.1\glassfish\domains\domain1\config\admin-keyfile how i can reset admin password?