How to use responseXML to parse xml

Hi,
I am sending this xml from server
<assignmentList>
<assignment>
<id>333</id><name>1170235257994</name><fileClass>4</fileClass><checked_out_by> </checked_out_by><status>s1</status><publication>p1</publication><section>s1</section><change_type>1</change_type><listenerClass>0</listenerClass>
</assignment>
<assignment>
<id>333</id><name>1170235257994</name><fileClass>4</fileClass><checked_out_by> </checked_out_by><status>s1</status><publication>p1</publication><section>s1</section><change_type>1</change_type><listenerClass>1</listenerClass>
</assignment>
</assignmentList>
I need to parse above xml to get id , name,fileclass etc
but in my js
var root = o.responseXML.documentElement;
var length=root.getElementsByTagName('assignment").length;
alert(length); // displays 0.
I need to get the length and iterate to get values from above two tags.
But could not achieve it.
but when I send
<assignmentList>
<assignment>
<id>333</id><name>1170235257994</name><fileClass>4</fileClass><checked_out_by> </checked_out_by><status>s1</status><publication>p1</publication><section>s1</section><change_type>1</change_type><listenerClass>0</listenerClass>
</assignment>
</assignmentList>
alert(length); // displays 1. correct
Can you please show me how I can get correct length and then get values from it
by getting values I mean
var assetId = root.getElementsByTagName('id').firstChild.nodeValue;
currently not working.
waiting for response
thanks

I have similar error
my servlet writer.
response.getWriter().write("<valid>pass</valid>");
        response.getWriter().write("<valid>fail</valid>");
        response.getWriter().write("<good>yes</good>");
        response.getWriter().write("<good>now</good>");
javascript
var msg = responseXML.getElementsByTagName("valid");
     document.getElementById('log').innerHTML  += "<br> " + msg + "....length=" + msg.length;
     for(i=0; i<msg.length; i++){
          document.getElementById('log').innerHTML  += "<br> " + msg.firstChild.nodeValue;
          var newOption = new Option(msg[i], "VALUE");
          document.inputForm.pendingMCObox.options[1] = newOption;
     msg = responseXML.getElementsByTagName("good");
     document.getElementById('log').innerHTML += "<br> " + msg + "....length=" + msg.length;
     for(i=0; i<msg.length; i++){
          document.getElementById('log').innerHTML += "<br> " + msg[i].firstChild.nodeValue;
          var newOption = new Option(msg[i], "VALUE");
          document.inputForm.pendingMCObox.options[1] = newOption;
for some reasons, the length is 0.  What am i doing wrong here?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • How to use if condition in XML Publisher Desk Top

    Hi..,
    How to use if condition in XML Publisher desk Top.
    Please guide me.
    Thanks,
    Suresh.

    What kind of condition you want to use?
    You can use Condition like this:
    <?xdofx:if condition then value1
    else if condition then Value2
    else Value3
    end if?>
    Please go thru XML Publisher User Guide.
    Thanks
    Ravi
    [email protected]

  • How to use the kxml parser?

    I am getting problem in using the kxml parser.Actually my application is showing the java.lang.NoClassDefFoundError: org/kxml/parser/XmlParser error.
    Can you tell me how to use the kxml parser with our j2me application or what are the steps for this?
    Whether we have to use the kxml.zip or some other JAR file for this?
    Again whether we have to set any classpath for this?

    I was getting same error using kxml parser. The reason is losing interface in which constants are declared.
    You need to correct code of kxml a bit.
    In every place where constant from XmlPullParser interface is referenced only by its name (without reference to its class XmlPullParser) you need to change for use full name. it means changes like:
    START_DOCUMENT to XmlPullParser.START_DOCUMENT
    Everywhere.
    That's all!

  • How to use Euro symbol in xml tags?

    How to use Euro symbol in xml tags?

    What do you mean by "in xml tags"? Can you post a three-line XML snippet showing what you hope to achieve?

  • How to ignore empty text element while using DOM to parse xml??

    hi everyone,
    i am using DOM to parse an xml file. But i dont know how to cinfig the DocumentBuilderFactory to ignore empty text elements.
    For example, i have an xml file like this:
    <?xml version="1.0" encoding="UTF-8" ?>
    <root>
        <child>Tom</child>
        <child>Jerry</child>
    </root>I used the following codes to parse:
    String fname = "Tom-and-Jerry.xml";
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setIgnoringElementContentWhitespace(true);
    factory.setIgnoringComments(true);
    DocumentBuilder builder = domFactory.newDocumentBuilder();
    // Generate a DOM tree from the DOM builder.
    org.w3c.dom.Document dom = builder.parse(new File(fname));
    org.w3c.dom.NodeList list = dom.getChildNodes();
    for (int i=0; i<list.getLength(); i++) {
        System.out.println("Child No."+i);
        System.out.println("NodeName="+list.item(i).getNodeName());
        System.out.println("NodeType="+getType(list.item(i).getNodeType()));
        System.out.println("NodeValue="+list.item(i).getNodeValue());
        System.out.println();
    }The result is not exactly what i want ---- there are 5 children in list!! The 1st, 3rd and 5th are #text and their values are all empty. Only the 2nd and the 4th are the child that i expect.
    It is really troublesome to get all these silly empty texts as sub elements. I tried to get rid of them, but i failed. I just dont understand why factory.setIgnoringElementContentWhitespace(true) did not work.
    Anyone can help me? thanks.
    Heavy ZHENG

    I just dont understand why factory.setIgnoringElementContentWhitespace(true) did not work.That only does something if the XML has a DTD that enables it to know what whitespace can be ignored and what is significant. The API documentation for the method refers you to this document:
    http://www.w3.org/TR/REC-xml#sec-white-space

  • How get DOCTYPE name when parsing XML Doc?

    My XML document has this:
    <!DOCTYPE Users SYSTEM "Users.dtd" []>
    So the name of this document's type is "Users", i.e. it is a Users document. However, I cannot figure out how to get that during parsing! I have set the following (and implemented all the correct interfaces):
         pa.setContentHandler( userHandler );
         pa.setDTDHandler( userHandler );
         pa.setEntityResolver( userHandler );
         pa.setErrorHandler( userHandler );My userHandler object is of class: XMLUserHandler (I made it up) that extends DefaultHandler and implements:
    DTDHandler, EntityResolver, ErrorHandler, ContentHandler
    and overrides all the nec. methods.
    What am I missing? how do I get it to return "Users" from:
    <!DOCTYPE Users SYSTEM "Users.dtd" []>
    or if it was:
    <!DOCTYPE MyDumbName SYSTEM "Users.dtd" []>
    how can I get it to return "MyDumbName"?
    Thank you all for your help in advance!

    For anyone wondering, the answer is to use LexicalHandler. However, they made it "hidden" in the sense that setting this property is not as easy as setting the ContentHandler, for example. Also, not every implementation has to recognize the LexicalHandler. You do it this way:
    //MY CLASS THAT IMPLEMENTS LexicalHandler INTERFACE
    MyLexicalHandler myHandler = new MyLexicalHandler();
    myXMLReader.setProperty( "http://xml.org/sax/properties/lexical-handler", myHandler );then just call "parse()" and it will automatically call your lexical handler, assuming it implements that.
    The main method in LexicalHandler here (i.e. the one that handles what I was looking for) is:
    public void startDTD(String name, String publicId, String systemId) throws SAXException

  • How to use SAX Parseto paser xml without root element

    Hello,
    I have big a xml file(500M) with without root element. How can I use SAXParse to parse it.

    A well-formed XML file has a single root element. Your parser can't deal with any other kind. So find the person who produced that file and explain politely that it's no good. (Hitting them with a big stick would be optional.)
    You could write a non-XML program that reads it in and creates a new version, wrapped in a single root element, if your supplier can't fix their problem.

  • How-to use Excel for the XML file input?

    Hello all,
    Following our discussion with Gerhard Steinhuber on the very nice tutorial from Horst Schaude , "How to upload mass data via XML File Input" , I am starting this new discussion.
    In the comments section of this previous cited tutorial, Rufat Gadirov explains how to use a generated XML from Eclipse instead of your XSD file as your source in Excel.
    However, in spite of all the instructions, I am still facing the same issue in Excel when I try to save my file as XML : "The XML maps in this workbook are not exportable".
    What I try to do is to create one or more Sales Orders with multiple Items in it from a XML File Input, using excel to enter data.
    The part with the File input is working (if I directly upload my file to the webDAV, it creates a sales order instance with multiple items).
    The only missing part is the Excel data input that I cannot make work. Any help on this matter would be greatly appreciated.
    Here is my XML file that I try to use as a source in Excel before inputing data from Excel:
    <?xml version="1.0" encoding="UTF-8"?>
    <p:MySalesOrderUploadedIntegrationInputRequest xmlns:p="http://001365xxx-one-off.sap.com/YUUD0G3OY_" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <MessageHeader>
        <CreationDateTime>2015-03-02T12:00:00.000Z</CreationDateTime>
    </MessageHeader>
        <List actionCode="01" listCompleteTransmissionIndicator="true" reconciliationPeriodCounterValue="0">
            <MySalesOrderUploaded>
              <MySalesOrderUploadedID>idvalue0</MySalesOrderUploadedID>
              <MyBuyerID schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeID="token">token</MyBuyerID>
              <MyDateTime>2015-03-02T12:00:00.000Z</MyDateTime>
              <MyName languageCode="EN">MyName</MyName>
              <MyBillToParty schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MyBillToParty>
              <MyDateToBeDelivered>2001-01-01</MyDateToBeDelivered>
              <MyEmployeeResponsible schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MyEmployeeResponsible>
              <MySalesUnit schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MySalesUnit>
                <MyItem>
                    <MyItemID>token</MyItemID>
                    <MyItemProductID schemeAgencyID="token" schemeID="token">token</MyItemProductID>
                    <MyItemDescription languageCode="EN">MyItemDescription</MyItemDescription>
                    <MyProductTypeCode>token</MyProductTypeCode>
                    <MyRequestedQuantity unitCode="token">0.0</MyRequestedQuantity>
                    <MyConfirmedQuantity unitCode="token">0.0</MyConfirmedQuantity>
                    <MyNetAmount currencyCode="token">0.0</MyNetAmount>
                </MyItem>
            </MySalesOrderUploaded>
            <MySalesOrderUploaded>
              <MySalesOrderUploadedID>idvalue0</MySalesOrderUploadedID>
              <MyBuyerID schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeID="token">token</MyBuyerID>
              <MyDateTime>2015-03-02T12:00:00.000Z</MyDateTime>
              <MyName languageCode="EN">MyName</MyName>
              <MyBillToParty schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MyBillToParty>
              <MyDateToBeDelivered>2001-01-01</MyDateToBeDelivered>
              <MyEmployeeResponsible schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MyEmployeeResponsible>
              <MySalesUnit schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MySalesUnit>
                <MyItem>
                    <MyItemID>token</MyItemID>
                    <MyItemProductID schemeAgencyID="token" schemeID="token">token</MyItemProductID>
                    <MyItemDescription languageCode="EN">MyItemDescription</MyItemDescription>
                    <MyProductTypeCode>token</MyProductTypeCode>
                    <MyRequestedQuantity unitCode="token">0.0</MyRequestedQuantity>
                    <MyConfirmedQuantity unitCode="token">0.0</MyConfirmedQuantity>
                    <MyNetAmount currencyCode="token">0.0</MyNetAmount>
                </MyItem>
            </MySalesOrderUploaded>
        </List>
    </p:MySalesOrderUploadedIntegrationInputRequest>
    Thank you all for your attention.
    Best regards.
    Jacques-Antoine Ollier

    Hello Jacques-Antoine,
    I suppose that as you have tried to construct a map from the schema, you have taken the elements from the List level down. In this case I also can't export the map.
    But if you take the elements from the level MySalesOrderUploaded down, you'll get the exportable map (screenshots)
    Best regards,
    Leonid Granatstein

  • How to apply condition when parsing XML using XMLTable

    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE 11.1.0.7.0 Production
    TNS for Linux: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - Production
    XML Response to be processed by stored proc:
    <TFSResponse>
    <TFS>
              <referenceNumber>39760</referenceNumber>
              <reqId>39760</reqId>
              <fromAccount>
                   <id>1550796</id>
                   <number>0003210011</number>
              </fromAccount>
              <toAccount>
                   <id>1550769</id>
                   <number>3199109643</number>
              </toAccount>
              <createdBy>
                   <userId>627892</userId>
                   <userLoginId>AAAAAA</userLoginId>
                   <userTypeId>1</userTypeId>
              </createdBy>
              </TFS>
    </TFSResponse>
    Register schema script:
    DECLARE
    l_schema CLOB;
    BEGIN
    l_schema := '<?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xdb="http://xmlns.oracle.com/xdb">
    <xs:element name="TFSResponse" type="TFSResponseWSResponseType" xdb:defaultTable="TEMP_RESULT" />
         <xs:complexType name="TFSResponseWSResponseType">
              <xs:sequence>
              <xs:element maxOccurs="unbounded" name="TFS" type="TFSSummaryWSTO"/>
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="TFSSummaryWSTO">
              <xs:sequence>
                   <xs:element name="referenceNumber" type="xs:string"/>
                   <xs:element name="reqId" type="xs:long"/>
                   <xs:element name="fromAccount" type="tns:AccountSummaryWSTO" />
    <xs:element name="toAccount" type="tns:AccountSummaryWSTO"/>
                   <xs:element name="createdBy" type="tns:userWSTO"/>
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="AccountSummaryWSTO">
              <xs:sequence>
                   <xs:element minOccurs="1" name="accountId" type="xs:long" />
                   <xs:element minOccurs="1" name="accountNumber" type="xs:string" />
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="userWSTO">
              <xs:sequence>
                   <xs:element name="userId" type="xs:long" />
                   <xs:element name="userLoginId" type="xs:string" />
                   <xs:element name="userTypeId" type="xs:short" />
              </xs:sequence>
         </xs:complexType>
    </xs:schema>';
    dbms_xmlSchema.registerSchema(schemaurl => 'TFSWebService_schema.xsd',
    schemadoc => l_schema,
    enableHierarchy => dbms_xmlschema.ENABLE_HIERARCHY_NONE);
    END;/
    Object Type:
    CREATE OR REPLACE TYPE DOC_ROWTYPE AS OBJECT
    REFERENCENUMBER VARCHAR2(255),
    REQID NUMBER(12),
    FROMACCOUNTID NUMBER(12),
    FROMACCOUNTNUMBER VARCHAR2(35),
    TOACCOUNTID NUMBER(12),
    TOACCOUNTNUMBER VARCHAR2(35),
    CREATEDBYUSERID NUMBER(12),
    CREATEDBYUSERLOGINID VARCHAR2(12)
    Collection Type:
    CREATE OR REPLACE TYPE DOC_TABLETYPE IS TABLE OF DOC_ROWTYPE;
    CREATE OR REPLACE PROCEDURE SP_TFS_REPORT (LoginId IN STRING,
    requestedByUser IN STRING,
    result_cursor OUT SYS_REFCURSOR)
    IS
    SYSTEM_USER VARCHAR2(12) := 'SYSTEM';
    l_http_request UTL_HTTP.req;
    l_http_response UTL_HTTP.resp;
    l_string_request VARCHAR2(1024);
    l_result_xml XMLTYPE;
    docExtTable_XML DOC_TABLETYPE := DOC_TABLETYPE();
    docExtRecord DOC_ROWTYPE;
    BEGIN
    l_string_request := .....(prepare web service request here)
    l_http_response := UTL_HTTP.get_response(l_http_request);
    resp_in_xml := XMLTYPE(l_clob_response);
    INSERT INTO TEMP_RESULT VALUES l_result_xml;
    SELECT DOC_ROWTYPE (t1.referenceNumber, t1.reqId, t2.accountId, t2.accountNumber, t3.accountId, t3.accountNumber,
                                                 t4.userLoginId, t4.userId)
    BULK COLLECT INTO docExtTable_XML
    FROM TEMP_RESULT ltr,
    XMLTABLE('/TFSResponse/TFS'
    PASSING ltr.object_value
    COLUMNS
    referenceNumber VARCHAR2(255 BYTE) PATH 'referenceNumber',
    reqId NUMBER(12)                PATH 'reqId',
    fromAccountXML XMLTYPE PATH 'fromAccount',
    toAccountXML XMLTYPE      PATH 'toAccount',
    createdByXML XMLTYPE      PATH 'createdBy'
    ) t1,
    XMLTABLE('/fromAccount'
    PASSING t1.fromAccountXML
    COLUMNS
    accountId NUMBER(12) PATH 'accountId',
    accountNumber VARCHAR2(35 BYTE) PATH 'accountNumber'
    ) t2,
    XMLTABLE('/toAccount'
    PASSING t1.toAccountXML
    COLUMNS
    accountId NUMBER(12) PATH 'accountId',
    accountNumber VARCHAR2(35 BYTE) PATH 'accountNumber'
    ) t3,
    XMLTABLE('/createdBy'
    PASSING t1.createdByXML
    COLUMNS
    userId NUMBER(12) PATH 'userId',
    userLoginId VARCHAR2(12 BYTE) PATH 'userLoginId' ----- This value should be set based on a condition*
    ) t4
    OPEN result_cursor FOR SELECT * FROM TABLE (DOC_TABLETYPE);
    COMMIT;
    END SP_TFS_REPORT
    The condition is like this
    IF (requestedByUser = true and createdByUserType = '2') then
    CREATEDBYUSERLOGINID := SYSTEM_USER;
    ELSE
         Take CREATEDBYUSERLOGINID from XML value 'userLoginId'
    where 'requestedByUser' is the input parameter to the stored procedure and 'createdByUserType' is the value from XML.
    'userTypeId' is not required to be set in collection.
    Now my question is how to put that condition when doing the XML parsing.
    Edited by: 991900 on Mar 19, 2013 9:54 AM

    Add a projection for "userTypeId" in T4, then use a CASE statement in the SELECT clause :
    SELECT  DOC_ROWTYPE (
            t1.referenceNumber, t1.reqId, t2.accountId, t2.accountNumber, t3.accountId, t3.accountNumber,
                                            t4.userId,
            CASE WHEN requestedByUser = 'true' AND t4.userTypeId = 2
                      THEN system_user
                 ELSE t4.userLoginId
            END
    BULK COLLECT INTO docExtTable_XML
        FROM TEMP_RESULT ltr,
        XMLTABLE('/TFSResponse/TFS'
                   PASSING ltr.object_value
                   COLUMNS
                       referenceNumber    VARCHAR2(255 BYTE)        PATH 'referenceNumber',
                       reqId              NUMBER(12)                   PATH 'reqId',                                       
                       fromAccountXML      XMLTYPE                  PATH 'fromAccount',                 
                       toAccountXML        XMLTYPE                     PATH 'toAccount',
                       createdByXML       XMLTYPE                     PATH 'createdBy'                                       
                    ) t1,
        XMLTABLE('/fromAccount'
                   PASSING t1.fromAccountXML
                   COLUMNS
                       accountId              NUMBER(12)    PATH 'accountId', 
                       accountNumber     VARCHAR2(35 BYTE)  PATH 'accountNumber'                                       
                   ) t2,
        XMLTABLE('/toAccount'
                   PASSING t1.toAccountXML
                   COLUMNS
                       accountId            NUMBER(12)    PATH 'accountId', 
                       accountNumber   VARCHAR2(35 BYTE)  PATH 'accountNumber'
                   ) t3,
        XMLTABLE('/createdBy'
                   PASSING t1.createdByXML
                   COLUMNS
                       userId           NUMBER(12)        PATH 'userId',
                       userLoginId      VARCHAR2(12 BYTE) PATH 'userLoginId',
                       userTypeId       NUMBER            PATH 'userTypeId'
                   ) t4
        ;

  • Question in using sockets in parsing XML!!!!(urgent plz help)

    i have a server/client program and the client has some XML files the server want to process and parse them using DOM.
    But i want to do this without having to transfer neither the whole file nor line-by-line of the file
    does anybody know how to do this???
    how to connect the output stream of the socket of the client with this file??
    thanks in advance

    i did it and here are the exact line of code to do it:
    DocumentBuilderFactory factory =
    DocumentBuilderFactory.newInstance();
    /factory.setValidating( true );
    // obtain object that builds Documents
    DocumentBuilder builder = factory.newDocumentBuilder();
    URL url = new URL("file://comp1/xml/Stack.xml");
    // obtain document object from XML document               Document document = builder.parse( url.openConnection() .getInputStream() );

  • How to use NodeIterator on an XML document

    I have been trying to create a NodeIterator using the following code:
    try
    FileInputStream inStream;
    Document doc;
    String xmlDocumentPath = "I have a real path here";
    inStream = new FileInputStream(xmlDocumentPath);
    DOMParser parser = new DOMParser();
    parser.parse(inStream);
    doc = parser.getDocument();
    Node root = doc.getDocumentElement();
    formInputFilter filter = new formInputFilter();
    DocumentTraversal traverse = (DocumentTraversal)doc;
    NodeIterator iter = traverse.createNodeIterator(root, NodeFilter.SHOW_ALL, filter, true);
    Node n = (Node)iter.nextNode();
    while (n != null)
    System.out.println(n.getNodeName());
    catch (Exception e)
    System.out.println(e.toString());
    When the nextNode method is executed I get an NPE. Looking in the iterator it shows the value of next as null when it is created. I have found a couple of code sources that all show this as the correct way to create a NodeIterator and I can't figure out what I am doing wrong. I have tried creating it with and without my filter and I still have the same problem. I had other code that could loop through the XML file that worked but the NodeIterator would be much simpler to use. Anyone have a suggestion.

    Using JDev 9.0.3.1, and with a C:\temp\test.xml file setup ahead of time, running the following program works for me just fine. How is yours different?
    package test;
    import java.io.FileInputStream;
    import oracle.xml.parser.v2.DOMParser;
    import org.w3c.dom.Document;
    import org.w3c.dom.Node;
    import org.w3c.dom.traversal.DocumentTraversal;
    import org.w3c.dom.traversal.NodeFilter;
    import org.w3c.dom.traversal.NodeIterator;
    public class Test {
      public static void main(String[] args) throws Throwable {
        Test t = new Test();
        t.test();
      void test() throws Throwable {
        String xmlDocumentPath = "c:\\temp\\test.xml";
        FileInputStream inStream = new FileInputStream(xmlDocumentPath);
        DOMParser parser = new DOMParser();
        parser.parse(inStream);
        Document doc = parser.getDocument();
        Node root = doc.getDocumentElement();
        MyNodeFilter filter = new MyNodeFilter();
        DocumentTraversal traverse = (DocumentTraversal)doc;
        NodeIterator iter = traverse.createNodeIterator(root, NodeFilter.SHOW_ALL, filter, true);
        Node n = null;
        while ((n = (Node)iter.nextNode()) != null) {
          System.out.println(n.getNodeName());
      class MyNodeFilter implements NodeFilter {
        public short acceptNode(Node n){
          return FILTER_ACCEPT;
    }

  • How to use STRANS to translate XML to ABAP with deep structure

    every experts, I want to use Tcode: STRANS to translate XML to ABAP, But it does not work well,
    here is XML code,I want to translate this XML into an an Inter table gt_orders with deep structure of oeb, and colum oeb is also and intertable,how can I do this.
    <?xml version="1.0" encoding="gb2312" ?><axmt410><ObjectID>setSalesOrder</ObjectID><azp01>000000</azp01><oea00>1</oea00><ta_oeaecn>SO-140227-3041</ta_oeaecn><oea03>25325017</oea03><oea02>2014-02-27 17:44:44.0</oea02><ta_oea002>2763.0</ta_oea002><ta_oea001>0.0</ta_oea001><oea14></oea14><oea15>25325017</oea15><oea23>RMB</oea23><oeaconf>S3</oeaconf><oea10></oea10><oeaud01>null</oeaud01><ta_oea007></ta_oea007><oea25>101</oea25><ta_oea008>0</ta_oea008><ta_oea009>null</ta_oea009><oeauser>Hanjingya</oeauser><ta_oeanday>2014-02-27 17:44:44.991</ta_oeanday><ta_oeamday>2014-02-28 08:30:14.866</ta_oeamday><ta_oeacday>2014-02-28 08:30:14.866</ta_oeacday><oeaud02>0</oeaud02><ta_oea030>null</ta_oea030><oeb><oeb03>1</oeb03><oeb04>7400208249</oeb04><oeb05>PCS</oeb05><oeb17>921.0</oeb17><oeb13>921.0</oeb13><oeb15></oeb15><oeb12>5</oeb12><oeb09>990001</oeb09><ta_oeb001></ta_oeb001><ta_oeb002>Yunnan</ta_oeb002><ta_oeb003>address1</ta_oeb003><ta_oeb004>zhangdagui、zhanglan</ta_oeb004><ta_oeb005>15974749998、15987782008</ta_oeb005><ta_oeb006>address and street</ta_oeb006><oebud01></oebud01></oeb><oeb><oeb03>2</oeb03><oeb04>7400208250</oeb04><oeb05>PCS</oeb05><oeb17>921.0</oeb17><oeb13>921.0</oeb13><oeb15></oeb15><oeb12>5</oeb12><oeb09>990001</oeb09><ta_oeb001></ta_oeb001><ta_oeb002>Yunnan</ta_oeb002><ta_oeb003>address2</ta_oeb003><ta_oeb004>zhangdagui、chenlan</ta_oeb004><ta_oeb005>15974749998、15987782008</ta_oeb005><ta_oeb006>address and street</ta_oeb006><oebud01></oebud01></oeb></axmt410>
    I write these codes in SAP XSLT  editor
    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
       <xsl:output encoding="iso-8859-1" indent="yes" method="xml" version="1.0"/>
       <xsl:strip-space elements="*"/>
       <xsl:strip-space elements="*"/>
       <xsl:template match="/">
         <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
           <asx:values>
             <ORDERS>
               <xsl:apply-templates select="//axmt410"/>
             </ORDERS>
           </asx:values>
         </asx:abap>
       </xsl:template>
       <xsl:template match="axmt410">
         <OBJECTID>
           <xsl:value-of select="ObjectID"/>
         </OBJECTID>
         <AZP01>
           <xsl:value-of select="azp01"/>
         </AZP01>
         <OEA00>
           <xsl:value-of select="oea00"/>
         </OEA00>
         <TA_OEAECN>
           <xsl:value-of select="ta_oeaecn"/>
         </TA_OEAECN>
         <OEA03>
           <xsl:value-of select="oea03"/>
         </OEA03>
         <OEA05>
           <xsl:value-of select="oea05"/>
         </OEA05>
         <OEA02>
           <xsl:value-of select="oea02"/>
         </OEA02>
         <TA_OEA002>
           <xsl:value-of select="ta_oea002"/>
         </TA_OEA002>
         <TA_OEA001>
           <xsl:value-of select="ta_oea001"/>
         </TA_OEA001>
         <OEA14>
           <xsl:value-of select="ora14"/>
         </OEA14>
         <OEA15>
           <xsl:value-of select="ora15"/>
         </OEA15>
         <OEA23>
           <xsl:value-of select="ora23"/>
         </OEA23>
         <OEACONF>
           <xsl:value-of select="oeaconf"/>
         </OEACONF>
         <OEA10>
           <xsl:value-of select="ora10"/>
         </OEA10>
         <OEAUD01>
           <xsl:value-of select="oeaud01"/>
         </OEAUD01>
         <TA_OEA007>
           <xsl:value-of select="ta_oea007"/>
         </TA_OEA007>
         <OEA25>
           <xsl:value-of select="ora25"/>
         </OEA25>
         <TA_OEA008>
           <xsl:value-of select="ta_oea008"/>
         </TA_OEA008>
         <TA_OEA009>
           <xsl:value-of select="ta_oea009"/>
         </TA_OEA009>
         <TA_OEA013>
           <xsl:value-of select="ta_oea013"/>
         </TA_OEA013>
         <TA_OEA014>
           <xsl:value-of select="ta_oea014"/>
         </TA_OEA014>
         <TA_OEA015>
           <xsl:value-of select="ta_oea015"/>
         </TA_OEA015>
         <TA_OEA016>
           <xsl:value-of select="ta_oea016"/>
         </TA_OEA016>
         <TA_OEA017>
           <xsl:value-of select="ta_oea017"/>
         </TA_OEA017>
         <TA_OEA018>
           <xsl:value-of select="ta_oea018"/>
         </TA_OEA018>
         <TA_OEA019>
           <xsl:value-of select="ta_oea019"/>
         </TA_OEA019>
         <TA_OEA020>
           <xsl:value-of select="ta_oea020"/>
         </TA_OEA020>
         <TA_OEA021>
           <xsl:value-of select="ta_oea021"/>
         </TA_OEA021>
         <TA_OEA022>
           <xsl:value-of select="ta_oea022"/>
         </TA_OEA022>
         <TA_OEA028>
           <xsl:value-of select="ta_oea028"/>
         </TA_OEA028>
         <OEAUSER>
           <xsl:value-of select="oeauser"/>
         </OEAUSER>
         <TA_OEANDAY>
           <xsl:value-of select="ta_oeanday"/>
         </TA_OEANDAY>
         <TA_OEAMDAY>
           <xsl:value-of select="ta_oeamday"/>
         </TA_OEAMDAY>
         <TA_OEACDAY>
           <xsl:value-of select="ta_oeacday"/>
         </TA_OEACDAY>
         <OEAUD02>
           <xsl:value-of select="oeaud02"/>
         </OEAUD02>
         <TA_OEA030>
           <xsl:value-of select="ta_oea030"/>
         </TA_OEA030>
         <OEB>
           <xsl:for-each select="oeb">
             <OEB03>
               <xsl:value-of select="oeb03"/>
             </OEB03>
             <OEB04>
               <xsl:value-of select="oeb04"/>
             </OEB04>
             <OEB05>
               <xsl:value-of select="oeb05"/>
             </OEB05>
             <OEB17>
               <xsl:value-of select="oeb17"/>
             </OEB17>
             <OEB13>
               <xsl:value-of select="oeb13"/>
             </OEB13>
             <OEB15>
               <xsl:value-of select="oeb15"/>
             </OEB15>
             <OEB12>
               <xsl:value-of select="oeb12"/>
             </OEB12>
             <OEB09>
               <xsl:value-of select="oeb09"/>
             </OEB09>
             <TA_OEB001>
               <xsl:value-of select="ta_oeb001"/>
             </TA_OEB001>
             <TA_OEB002>
               <xsl:value-of select="ta_oeb002"/>
             </TA_OEB002>
             <TA_OEB003>
               <xsl:value-of select="ta_oeb003"/>
             </TA_OEB003>
             <TA_OEB004>
               <xsl:value-of select="ta_oeb004"/>
             </TA_OEB004>
             <TA_OEB005>
               <xsl:value-of select="ta_oeb005"/>
             </TA_OEB005>
             <TA_OEB006>
               <xsl:value-of select="ta_oeb006"/>
             </TA_OEB006>
             <OEBUD01>
               <xsl:value-of select="oebud01"/>
             </OEBUD01>
           </xsl:for-each>
         </OEB>
       </xsl:template>
    </xsl:transform>
    and I use below ABAP program for a test, but the items from XML can not translate into Interner table gt_orders-oeb[]
    TYPE-POOLS abap.
    CONSTANTS gs_file TYPE string VALUE 'C:\temp\order02.xml'.
    * This is the structure for the data from the XML file
    TYPES:
       BEGIN OF typ_s_oeb,
         oeb03     TYPE string,    "
         oeb04     TYPE string,    "
         oeb05     TYPE string,    "
         oeb17     TYPE string,    "
         oeb13     TYPE string,   
         oeb15     TYPE string,   
         oeb12     TYPE string,    "
         oeb09     TYPE string,    "
         ta_oeb001 TYPE string,    "
         ta_oeb002 TYPE string,    "
         ta_oeb003 TYPE string,    "
         ta_oeb004 TYPE string,    "
         ta_oeb005 TYPE string,    "
         ta_oeb006 TYPE string,    "
         ta_oeb013 TYPE string,    "
         ta_oeb014 TYPE string,    "
         ta_oeb015 TYPE string,    "
         ta_oeb016 TYPE string,    "
         ta_oeb017 TYPE string,    "
         ta_oeb018 TYPE string,    "
         ta_oeb019 TYPE string,    "
         ta_oeb020 TYPE string,    "
         ta_oeb021 TYPE string,    "
         ta_oeb022 TYPE string,    "
         oebud01   TYPE string,    "
       END OF typ_s_oeb.
    TYPES: typ_t_oeb TYPE TABLE OF typ_s_oeb WITH KEY oeb03.
    TYPES:
       BEGIN OF typ_s_order,
         objectid   TYPE string,   "
         azp01      TYPE string,   "
         oea00      TYPE string,   "
         ta_oeaecn  TYPE string,   "
         oea03      TYPE string,   "
         oea02      TYPE string,   "
         ta_oea002  TYPE string,   "
         ta_oea001  TYPE string,   "
         oea14      TYPE string,   "
         oea15      TYPE string,  
         oea23      TYPE string,   "
         oeaconf    TYPE string,   "
         oea10      TYPE string,   "
         oeaud01    TYPE string,   "
         ta_oea007  TYPE string,   "
         oea25      TYPE string,   "
         ta_oea008  TYPE string,   "
         ta_oea009  TYPE string,   "
         oeauser    TYPE string,   "
         ta_oeanday TYPE string,   "
         ta_oeamday TYPE string,   "
         ta_oeacday TYPE string,   "
         oeaud02    TYPE string,   "
         ta_oea030  TYPE string,   "
         ta_oea013  TYPE string,
         ta_oea014  TYPE string,
         ta_oea015  TYPE string,
         ta_oea016  TYPE string,
         ta_oea017  TYPE string,
         ta_oea018  TYPE string,
         ta_oea019  TYPE string,
         ta_oea020  TYPE string,
         ta_oea021  TYPE string,
         ta_oea022  TYPE string,
         ta_oea025  TYPE string,
         oeb        TYPE typ_t_oeb,
        END OF typ_s_order.
    * Table for the XML content
    DATA: gt_itab       TYPE STANDARD TABLE OF char2048,
           gs_itab       LIKE LINE OF gt_itab.
    * Table and work ares for the data from the XML file
    DATA: gt_orders     TYPE STANDARD TABLE OF typ_s_order,
           gs_orders     TYPE typ_s_order.
    * Result table that contains references
    * of the internal tables to be filled
    DATA: gt_result_xml TYPE abap_trans_resbind_tab,
           gs_result_xml TYPE abap_trans_resbind.
    * For error handling
    DATA: gs_rif_ex     TYPE REF TO cx_root,
           gs_var_text   TYPE string.
    * Get the XML file from your client
    CALL METHOD cl_gui_frontend_services=>gui_upload
       EXPORTING
         filename                = gs_file
       CHANGING
         data_tab                = gt_itab
       EXCEPTIONS
         file_open_error         = 1
         file_read_error         = 2
         no_batch                = 3
         gui_refuse_filetransfer = 4
         invalid_type            = 5
         no_authority            = 6
         unknown_error           = 7
         bad_data_format         = 8
         header_not_allowed      = 9
         separator_not_allowed   = 10
         header_too_long         = 11
         unknown_dp_error        = 12
         access_denied           = 13
         dp_out_of_memory        = 14
         disk_full               = 15
         dp_timeout              = 16
         not_supported_by_gui    = 17
         error_no_gui            = 18
         OTHERS                  = 19.
    IF sy-subrc <> 0.
       MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    * Fill the result table with a reference to the data table.
    * Within the XSLT stylesheet, the data table can be accessed with
    * "IPERSON".
    GET REFERENCE OF gt_orders INTO gs_result_xml-value.
    gs_result_xml-name = 'ORDERS'.
    APPEND gs_result_xml TO gt_result_xml.
    * Perform the XSLT styleshee
    TRY.
         CALL TRANSFORMATION zfx_so_xml_to_abap
         SOURCE XML gt_itab
         RESULT (gt_result_xml).
       CATCH cx_root INTO gs_rif_ex.
         gs_var_text = gs_rif_ex->get_text( ).
         MESSAGE gs_var_text TYPE 'S'.
    ENDTRY.
    LOOP AT gt_orders INTO gs_orders.
    ENDLOOP.

    The simplest way seems to me is to use a XSL file for that. The <xsl:output> attributes doctype-system and doctype-public generate the DTD declaration <!DOCTYPE YOUR_ROOT SYSTEM "yourDTDfile.dtd"> and <!DOCTYPE YOUR_ROOT PUBLIC "yourDTDfile.dtd">, respectively.
    When calling transformerInstance.transform() the XSLT processor performs the identity transformation - it just copies elements, attributes, content, processing instructions and comments to the result stream.
    If you're using an xsl file for your transformation already, simply add <xsl:output doctype-system="yourDTDfile.dtd"/> to your existing XSL file.
    If you're only using the identity transformation you'd need to change the line of code where you obtain the transformer instance from the TransformerFactory to:
    t_factory.newTransformer(new StreamSource("test.xsl"));
    and use this as test.xsl:
    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
       <xsl:output doctype-system="yourDTDfile.dtd"/>
       <!-- this is the identity transformation -->
       <xsl:template match="*|@*|comment()|processing-instruction()|text()">
          <xsl:copy>
             <xsl:apply-templates select="*|@*|comment()|processing-instruction()|text()"/>
          </xsl:copy>
       </xsl:template>
    </xsl:stylesheet>Good luck.

  • How to use the api in xml format

    Hi All,
    I want make a call to the following api
    <Reload
    Pin = xs:string
    ReloadCard = xs:string>
    Amount
    </Reload>
    Where in Reload is an api accepting pin and reload card as attributes.
    How would i call this Reload using java?
    Thank You

    The documentation probably also talks about how that's exposed, as in whether there's an HTTP endpoint available, or something. You might have to save that XML to a file in a particular location, or pump it down a socket. Who knows? Talk to your vendor. What is that XML for anyway, some e-gift scheme?

  • How to use download listener for xml files?

    Hi all,
    In my usecase I should write the xml contents to the file using Output Stream writer.
    As of now I am using the below lines of code in the download listener method.
    String s = myDoc.getContent().toString();
    w.write(s);
    myDoc is my xml document. I can see the file but there is no content.
    Kindly come out with your help in which I could achieve this.
    Thanks,
    Phani.

    Hi john,
    What all I am trying to ask is how could I write xml data to external file by clicking a button or a link etc.. which is in the JSF page.
    Now for that I created a button and dragged the <af:fileDownloadActionListener> into the button.
    I binded the listener with the backing bean method.
    public void sayHello(FacesContext context, OutputStream out) throws IOException
    OutputStreamWriter w = new OutputStreamWriter(out, "UTF-8");
    IDocument myDoc = new Document2004();
    myDoc.addEle("sai");
    w.write(myDoc.getContent().toString());
    w.flush();
    in the method you can see IDocument that is an interface which I have in the external JAR files that I am using to write data to MS Word.
    The myDoc which I created as an object of IDocument has lot of methods in which I am using addEle(String) which writes a string to word document.
    in the writer object writer I am getting the content of the myDoc inorder to convert that to string as it will be in xml format.
    When I am writing every thing I can download and save the document but unable to see the data that I have written that is "*sai*" instead a blank page is getting opened.
    When I do the same with Creating a file object in the local disc using File f = new File(path) rather than downloading it using the listener I can see the contents what I have written.
    This is what all I mean to ask. Kindly come up with your help
    Thanks,
    Phani.

  • How to ignore DOCTYPE when parsing xml java?

    Hello
    i am trying to parse some sml files that have:
    <!DOCTYPE ModuleRoot SYSTEM "C:\xxx\xmlapp.dtd">
    i don;t have the dtd file
    how can i ignore it by changing my code and not changing the xml file.
    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
    this.doc = documentBuilder.parse(xmlFileName);
    i got exception in this.doc = documentBuilder.parse(xmlFileName);
    (The system cannot find the path specified)
    Thanks in advance.

    You need to create an EntityResolver that returns a dummy DTD. Since you aren't actually validating, this can be as simple as:
            db.setEntityResolver(new EntityResolver()
                public InputSource resolveEntity(String publicId, String systemId)
                    throws SAXException, IOException
                    return new InputSource(new StringReader(""));
            });For more information, here's an article that I wrote on [XML parsing and validation|http://www.kdgregory.com/index.php?page=xml.parsing].

Maybe you are looking for

  • Multiple device syncing advice needed and appreciated.

    Hey everyone, happy holidays to everyone I need some advice from you Apple lovers out there if you can spend some time replying.  Thanks alot in advanced My devices and current status 13" Macbook Pro with 8gig RAM with lion OS - Mosty used for word p

  • HT5527 is there a way to merge two iCloud accounts?

    I have two Apple IDs, one I used to set up iTunes and that syncs to my Phone and Computer, and an old MobileMe account that I mostly used for syncing my calendars, contacts and storing files online. I was able to sync my contacts but I'd like to have

  • BPM Alert shows in Inbox but without custom text

    We have a BPM which raises an alert and passes a message to a fixed receipent Inbox. In our Dev environment this works great. We replicated this functinoality in our QA environment and now the user gets an alert in their Inbox but instead of the cust

  • Create and Remove Enhancement Implementation in WD ABAP!!!

    Hi Experts, I have Created an Enhancement implementation in a standard Web Dynpro ABAP component and added a new view in the component. Now I need to remove this enhancement implementation. Can anybody please suggest how to do it. In normal ABAP code

  • Using of CONVERT DATE

    Hello, I have two questions relating to a part of a source code, which I have to analyze:   CONVERT DATE INTAB-DATUM INTO INVERTED-DATE DAT_INV.   SELECT SINGLE * FROM TCURR WHERE KURST = INTAB-KURST AND                                              F