Replace a line on XML file

If I have a XML file, like:
  <?xml version="1.0" ?>
- <Fibonacci_Numbers>
  <fibonacci>1</fibonacci>
  <fibonacci>1</fibonacci>
  <fibonacci>2</fibonacci>
  <fibonacci>3</fibonacci>
  <fibonacci>5</fibonacci>
  <fibonacci>8</fibonacci>
  <fibonacci>13</fibonacci>
  <fibonacci>21</fibonacci>
  <fibonacci>34</fibonacci>
  <fibonacci>55</fibonacci>
  </Fibonacci_Numbers>and want to replace the number "21" for "37", without rewrite the whole file, how can I proceed?
I writing the XML file with the PrintWriter API, and read I will try to read with the Element API, have some way to read the "fibonacci" attribute in the N-th position and replace it?
Thanks in advance!

If you want to change something in a text file, then by far the best way to do that is to create a new version of the file. That's what everybody always does. Why do you think you don't want to do that?

Similar Messages

  • How to replace a line ina text file using java?

    Hi ALL,
    Does anybody know how to replace a line in a text file uisng java.

    use this thing:
    http://doesthatevencompile.com/current-projects/code-sniplets/ASCIIFile.htm
    open the file,
    read its contents, replace the text you need in the contents, set the contents back into the file.
    it takes care of the IO for you.

  • Xtra characters & line in XML file

    I have a file with several errors in our xml file created by Oracle, it is adding an extra character in the strings and created a second line for that string, which we have not been able to fix(see example) any ideas would be appreciated.
    name = "BOX_NBR">1</variable><variable
    name = "TOTAL_BOXES">2</variable><
    *<variable_*
    name = "DELIVERY_ID">5257664</variable><variable
    name = "PICKING_ORDER">20104</variable><variable

    Hi this is how the file generating and this is working when we run the job for number of labels up to 8 and when we try to run the job having more than 8 it is generating like below and if you look for the label 9 for one of the field it is having << characters instaed of one < before Variable name
    </variable><<variable name = "LOE">46
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!-- Whitespace is not allowed at this location. -->
    <!DOCTYPE labels SYSTEM "C:\Program Files\Loftware Labeling\label.dtd">
    <labels FORMAT="HOOKBOXI.lwl" PRINTERNAME="hisspq1" JOBNAME="1951594" QUANTITY="1">
    <label><variable name = "LABEL_NUMBER">1</variable><variable name = "JOB">1951594</variable><variable name = "ASSEMBLY">6331M-7</variable><variable name = "FIXED_LOT_MULT">4</variable><variable name = "JOB_QTY">36</variable><variable name = "DUE_DATE">2013-03-16</variable><variable name = "WIRE">C072</variable><variable name = "HOOK_MACH">PLTN</variable><variable name = "LBS_TRAY">0</variable><variable name = "FINISH">TIN1</variable><variable name = "HEAT_TREAT">485</variable><variable name = "MYLAR_TEST_H">None</variable><variable name = "MYLAR_TEST_F">None</variable><variable name = "CLASS_CODE">DISCRETE</variable><variable name = "LOCATION">BLKSTG</variable><variable name = "SUBINV">STOCKROOM</variable><variable name = "DESCRIP">RNGE KOFFSET</variable><variable name = "LOE">46</variable><variable name = "FBDRAW">D#6331-7</variable><variable name = "PRINT_DATE">2013-03-18</variable><variable name = "NBR_LABELS">9</variable><variable name = "FY1">1</variable><variable name = "FY2">3</variable>
    </label>
    <label><variable name = "LABEL_NUMBER">2</variable><variable name = "JOB">1951594</variable><variable name = "ASSEMBLY">6331M-7</variable><variable name = "FIXED_LOT_MULT">4</variable><variable name = "JOB_QTY">36</variable><variable name = "DUE_DATE">2013-03-16</variable><variable name = "WIRE">C072</variable><variable name = "HOOK_MACH">PLTN</variable><variable name = "LBS_TRAY">0</variable><variable name = "FINISH">TIN1</variable><variable name = "HEAT_TREAT">485</variable><variable name = "MYLAR_TEST_H">None</variable><variable name = "MYLAR_TEST_F">None</variable><variable name = "CLASS_CODE">DISCRETE</variable><variable name = "LOCATION">BLKSTG</variable><variable name = "SUBINV">STOCKROOM</variable><variable name = "DESCRIP">RNGE KOFFSET</variable><variable name = "LOE">46</variable><variable name = "FBDRAW">D#6331-7</variable><variable name = "PRINT_DATE">2013-03-18</variable><variable name = "NBR_LABELS">9</variable><variable name = "FY1">1</variable><variable name = "FY2">3</variable>
    </label>
    <label><variable name = "LABEL_NUMBER">3</variable><variable name = "JOB">1951594</variable><variable name = "ASSEMBLY">6331M-7</variable><variable name = "FIXED_LOT_MULT">4</variable><variable name = "JOB_QTY">36</variable><variable name = "DUE_DATE">2013-03-16</variable><variable name = "WIRE">C072</variable><variable name = "HOOK_MACH">PLTN</variable><variable name = "LBS_TRAY">0</variable><variable name = "FINISH">TIN1</variable><variable name = "HEAT_TREAT">485</variable><variable name = "MYLAR_TEST_H">None</variable><variable name = "MYLAR_TEST_F">None</variable><variable name = "CLASS_CODE">DISCRETE</variable><variable name = "LOCATION">BLKSTG</variable><variable name = "SUBINV">STOCKROOM</variable><variable name = "DESCRIP">RNGE KOFFSET</variable><variable name = "LOE">46</variable><variable name = "FBDRAW">D#6331-7</variable><variable name = "PRINT_DATE">2013-03-18</variable><variable name = "NBR_LABELS">9</variable><variable name = "FY1">1</variable><variable name = "FY2">3</variable>
    </label>
    <label><variable name = "LABEL_NUMBER">4</variable><variable name = "JOB">1951594</variable><variable name = "ASSEMBLY">6331M-7</variable><variable name = "FIXED_LOT_MULT">4</variable><variable name = "JOB_QTY">36</variable><variable name = "DUE_DATE">2013-03-16</variable><variable name = "WIRE">C072</variable><variable name = "HOOK_MACH">PLTN</variable><variable name = "LBS_TRAY">0</variable><variable name = "FINISH">TIN1</variable><variable name = "HEAT_TREAT">485</variable><variable name = "MYLAR_TEST_H">None</variable><variable name = "MYLAR_TEST_F">None</variable><variable name = "CLASS_CODE">DISCRETE</variable><variable name = "LOCATION">BLKSTG</variable><variable name = "SUBINV">STOCKROOM</variable><variable name = "DESCRIP">RNGE KOFFSET</variable><variable name = "LOE">46</variable><variable name = "FBDRAW">D#6331-7</variable><variable name = "PRINT_DATE">2013-03-18</variable><variable name = "NBR_LABELS">9</variable><variable name = "FY1">1</variable><variable name = "FY2">3</variable>
    </label>
    <label><variable name = "LABEL_NUMBER">5</variable><variable name = "JOB">1951594</variable><variable name = "ASSEMBLY">6331M-7</variable><variable name = "FIXED_LOT_MULT">4</variable><variable name = "JOB_QTY">36</variable><variable name = "DUE_DATE">2013-03-16</variable><variable name = "WIRE">C072</variable><variable name = "HOOK_MACH">PLTN</variable><variable name = "LBS_TRAY">0</variable><variable name = "FINISH">TIN1</variable><variable name = "HEAT_TREAT">485</variable><variable name = "MYLAR_TEST_H">None</variable><variable name = "MYLAR_TEST_F">None</variable><variable name = "CLASS_CODE">DISCRETE</variable><variable name = "LOCATION">BLKSTG</variable><variable name = "SUBINV">STOCKROOM</variable><variable name = "DESCRIP">RNGE KOFFSET</variable><variable name = "LOE">46</variable><variable name = "FBDRAW">D#6331-7</variable><variable name = "PRINT_DATE">2013-03-18</variable><variable name = "NBR_LABELS">9</variable><variable name = "FY1">1</variable><variable name = "FY2">3</variable>
    </label>
    <label>
    <variable name = "LABEL_NUMBER">6</variable><variable name = "JOB">1951594</variable><variable name = "ASSEMBLY">6331M-7</variable><variable name = "FIXED_LOT_MULT">4</variable><variable name = "JOB_QTY">36</variable><variable name = "DUE_DATE">2013-03-16</variable><variable name = "WIRE">C072</variable><variable name = "HOOK_MACH">PLTN</variable><variable name = "LBS_TRAY">0</variable><variable name = "FINISH">TIN1</variable><variable name = "HEAT_TREAT">485</variable><variable name = "MYLAR_TEST_H">None</variable><variable name = "MYLAR_TEST_F">None</variable><variable name = "CLASS_CODE">DISCRETE</variable><variable name = "LOCATION">BLKSTG</variable><variable name = "SUBINV">STOCKROOM</variable><variable name = "DESCRIP">RNGE KOFFSET</variable><variable name = "LOE">46</variable><variable name = "FBDRAW">D#6331-7</variable><variable name = "PRINT_DATE">2013-03-18</variable><variable name = "NBR_LABELS">9</variable><variable name = "FY1">1</variable><variable name = "FY2">3</variable>
    </label>
    <label><variable name = "LABEL_NUMBER">7</variable><variable name = "JOB">1951594</variable><variable name = "ASSEMBLY">6331M-7</variable><variable name = "FIXED_LOT_MULT">4</variable><variable name = "JOB_QTY">36</variable><variable name = "DUE_DATE">2013-03-16</variable><variable name = "WIRE">C072</variable><variable name = "HOOK_MACH">PLTN</variable><variable name = "LBS_TRAY">0</variable><variable name = "FINISH">TIN1</variable><variable name = "HEAT_TREAT">485</variable><variable name = "MYLAR_TEST_H">None</variable><variable name = "MYLAR_TEST_F">None</variable><variable name = "CLASS_CODE">DISCRETE</variable><variable name = "LOCATION">BLKSTG</variable><variable name = "SUBINV">STOCKROOM</variable><variable name = "DESCRIP">RNGE KOFFSET</variable><variable name = "LOE">46</variable><variable name = "FBDRAW">D#6331-7</variable><variable name = "PRINT_DATE">2013-03-18</variable><variable name = "NBR_LABELS">9</variable><variable name = "FY1">1</variable><variable name = "FY2">3</variable>
    </label>
    <label><variable name = "LABEL_NUMBER">8</variable><variable name = "JOB">1951594</variable><variable name = "ASSEMBLY">6331M-7</variable><variable name = "FIXED_LOT_MULT">4</variable><variable name = "JOB_QTY">36</variable><variable name = "DUE_DATE">2013-03-16</variable><variable name = "WIRE">C072</variable><variable name = "HOOK_MACH">PLTN</variable><variable name = "LBS_TRAY">0</variable><variable name = "FINISH">TIN1</variable><variable name = "HEAT_TREAT">485</variable><variable name = "MYLAR_TEST_H">None</variable><variable name = "MYLAR_TEST_F">None</variable><variable name = "CLASS_CODE">DISCRETE</variable><variable name = "LOCATION">BLKSTG</variable><variable name = "SUBINV">STOCKROOM</variable><variable name = "DESCRIP">RNGE KOFFSET</variable><variable name = "LOE">46</variable><variable name = "FBDRAW">D#6331-7</variable><variable name = "PRINT_DATE">2013-03-18</variable><variable name = "NBR_LABELS">9</variable><variable name = "FY1">1</variable><variable name = "FY2">3</variable>
    </label>
    <label><variable name = "LABEL_NUMBER">9</variable><variable name = "JOB">1951594</variable><variable name = "ASSEMBLY">6331M-7</variable><variable name = "FIXED_LOT_MULT">4</variable><variable name = "JOB_QTY">36</variable><variable name = "DUE_DATE">2013-03-16</variable><variable name = "WIRE">C072</variable><variable name = "HOOK_MACH">PLTN</variable><variable name = "LBS_TRAY">0</variable><variable name = "FINISH">TIN1</variable><variable name = "HEAT_TREAT">485</variable><variable name = "MYLAR_TEST_H">None</variable><variable name = "MYLAR_TEST_F">None</variable><variable name = "CLASS_CODE">DISCRETE</variable><variable name = "LOCATION">BLKSTG</variable><variable name = "SUBINV">STOCKROOM</variable><variable name = "DESCRIP">RNGE KOFFSET</variable><<variable name = "LOE">46</variable><variable name = "FBDRAW">D#6331-7</variable><variable name = "PRINT_DATE">2013-03-18</variable><variable name = "NBR_LABELS">9</variable><variable name = "FY1">1</variable><variable name = "FY2">3</variable>
    </label>
    </labels>
    Appreciate for your help.

  • Flash Pro CS6 BUG - inconsistent end of line for xml files in library saved in xfl - MESSES UP SVN

    When saving in XFL with Flash CS6 on Mac (it also happened in CS5.5), the generated xml files in library often have inconsistend end of line, which blocks SVN commits and I have to manually go in the files and make them consistent.
    The XML nodes themselves all have \r\l as end of line, while, within <[CDATA[]]>, they only have \r.
    We think this happens only when creating new library items on mac, on windows it doesn't happen.
    This slows us down incredibly when working on a team using svn.
    SVN doesn't upload files with inconsistend line ending.
    Line ending shoul be consistent within the same xml file to make svn operations smooth.
    Check an image of the bug:
    http://www.pippoflash.com/_test/flash_bug_eof.png
    you can see clearly the differences.
    thank you
    Filippo

    Thanks Filippo, I could see that now!
    While I was investigating this, I found that this is even happening on a file created and saved on just Windows. I was able to reproduce this using the following steps
    - Create a new AS3 file on Windows
    - Drag out a component to the stage say a Button component from the User Interface section of the Components panel
    - Convert the button component to a Movie Clip Symbol
    - Save the file as XFL and examine the Library XML files (the End of Line is just 'LF' in CDATA section whereas it is 'CR LF' everywhere else)
    Since you were saying 'Items created in windows have no problem', does that means, SVN can commit those without any issues for you? And do you face problem only when the file is Created and Saved on Mac(where the end of line is just LF every where) but Modified and Re-saved on Windows(where the end of line is inconsistent)? 
    Thanks!
    Mohan

  • How to remove empty lines from xml files after removing nodes from document

    <pre>
    Hi
    <b>i have xml document, which is shown below
    after removing some nodes from the document ,i am getting empty lines in place of removed nodes,how to resolve this and get the proper xml document without any errors</b>
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!DOCTYPE Message SYSTEM "TRD01.dtd">
    <Message>
    <Header>
    <CounterPartyType>CLIENT</CounterPartyType>
    <CreationTime>20134455</CreationTime>
    <ErrorCode>363 </ErrorCode>
    <ErrorEnterPriseId>N</ErrorEnterPriseId>
    <ErrorStatus>1</ErrorStatus>
    <ErrorSystemId>STL</ErrorSystemId>
    <ErrorTimes>31</ErrorTimes>
    <MessageType>T</MessageType>
    <RecipientEnterpriseId>N</RecipientEnterpriseId>
    <RecipentSystemId>EXM</RecipentSystemId>
    <Remarks>REMARSK</Remarks>
    <SenderEnterpriseId>N</SenderEnterpriseId>
    <SenderSystemId>TR</SenderSystemId>
    </Header>
    </Message>
    <ErrorCode>363 </ErrorCode>
    <ErrorEnterPriseId>NIHK</ErrorEnterPriseId>
    <ErrorStatus>1</ErrorStatus>
    <ErrorSystemId>STL</ErrorSystemId>
    <ErrorTimes>31</ErrorTimes>
    XPathExpression expression5 = xpath.compile(xmlpath5);
    Object result5 = expression5.evaluate(doc, XPathConstants.NODE);
    Node node5 = (Node) result5;
    node5.getParentNode().removeChild(node5);
    XPathExpression expression6 = xpath.compile(xmlpath6);
    Object result6 = expression6.evaluate(doc, XPathConstants.NODE);
    Node node6=(Node) result6;
    node6.getParentNode().removeChild(node6);
    XPathExpression expression7 = xpath.compile(xmlpath7);
    Object result7 = expression7.evaluate(doc, XPathConstants.NODE);
    Node node7=(Node) result7;
    node7.getParentNode().removeChild(node7);
    doc.normalize();
    doc.normalizeDocument();
    TransformerFactory tf = TransformerFactory.newInstance();
    Transformer t = tf.newTransformer();
    t.setOutputProperty(OutputKeys.INDENT, "yes");
    t.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
    t.setOutputProperty(OutputKeys.METHOD,"xml");
    t.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
    the xml output i am getting is
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <Message>
    <Header>
    <CounterPartyType>CLIENT</CounterPartyType>
    <CreationTime>20134455</CreationTime>
    <MessageType>TRD01</MessageType>
    <RecipientEnterpriseId>N</RecipientEnterpriseId>
    <RecipentSystemId>STL</RecipentSystemId>
    <Remarks>REMARSK</Remarks>
    <SenderEnterpriseId>N</SenderEnterpriseId>
    <SenderSystemId>T</SenderSystemId>
    </Header>
    </Message>
    <b>could you please let me know how to avoid empty lines in the xml doucment output</b>
    this is the method i am using to get the result
    public void ValidateRecord(String xml){
    try{
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = factory.newDocumentBuilder();
    //parse file into DOM
    /*DOMParser parser = new DOMParser();
    parser.setErrorStream(System.err);
    parser.setValidationMode(DTD_validation);
    parser.showWarnings(true);*/
    System.out.println ("HI THIS xml is validation "+xml);
    Resolver res = new Resolver();
    db.setEntityResolver(res);
    Document doc = db.parse(new InputSource(new StringReader(xml)));
    XPathFactory xpf = XPathFactory.newInstance();
    XPath xpath = xpf.newXPath();
    // XPathExpression expression = xpath.compile("//A/B[C/E/text()=13]");
    String xmlpath="/Message/Header/CounterPartyType/text()";
    String xmlpath1="/Message/Header/RecipentSystemId/text()";
    String xmlpath2="/Message/Header/ErrorSystemId/text()";
    XPathExpression expression = xpath.compile(xmlpath);
    XPathExpression expression1 = xpath.compile(xmlpath2);
    Object result = expression.evaluate(doc, XPathConstants.NODE);
    Object result1 = expression1.evaluate(doc, XPathConstants.NODE);
    Node node = (Node) result;
    Node node1 = (Node) result1;
    System.out.println("the values of the string is " +node.getNodeValue());
    System.out.println("the values of the string is " +node1.getNodeValue());
    // for (int i = 0; i < nodes.getLength(); i++) {
    //System.out.println(nodes.item(i).getNodeValue());
    // CAHNGING THE RECEIPENT NODE
    XPathExpression expression2 = xpath.compile(xmlpath1);
    Object result2 = expression2.evaluate(doc, XPathConstants.NODE);
    Node node2 = (Node) result2;
    System.out.println(node2);
    node2.setNodeValue(node1.getNodeValue());
    System.out.println(node2);
    //removing the nodes from document
    String xmlpath3="/Message/Header/ErrorCode";
    String xmlpath4="/Message/Header/ErrorEnterPriseId";
    String xmlpath5="/Message/Header/ErrorStatus";
    String xmlpath6="/Message/Header/ErrorSystemId";
    String xmlpath7="/Message/Header/ErrorTimes";
    XPathExpression expression3 = xpath.compile(xmlpath3);
    Object result3 = expression3.evaluate(doc, XPathConstants.NODE);
    Node node3 = (Node) result3;
    node3.getParentNode().removeChild(node3);
    XPathExpression expression4 = xpath.compile(xmlpath4);
    Object result4 = expression4.evaluate(doc, XPathConstants.NODE);
    Node node4 = (Node) result4;
    System.out.println("node value");
    System.out.println(node4.getParentNode().getNodeName());
    node4.getParentNode().removeChild(node4);
    XPathExpression expression5 = xpath.compile(xmlpath5);
    Object result5 = expression5.evaluate(doc, XPathConstants.NODE);
    Node node5 = (Node) result5;
    node5.getParentNode().removeChild(node5);
    XPathExpression expression6 = xpath.compile(xmlpath6);
    Object result6 = expression6.evaluate(doc, XPathConstants.NODE);
    Node node6=(Node) result6;
    node6.getParentNode().removeChild(node6);
    XPathExpression expression7 = xpath.compile(xmlpath7);
    Object result7 = expression7.evaluate(doc, XPathConstants.NODE);
    Node node7=(Node) result7;
    node7.getParentNode().removeChild(node7);
    // Node b13Node = (Node) expression.evaluate(doc, XPathConstants.NODE);
    //b13Node.getParentNode().removeChild(b13Node);
    doc.normalize();
    doc.normalizeDocument();
    TransformerFactory tf = TransformerFactory.newInstance();
    Transformer t = tf.newTransformer();
    t.setOutputProperty(OutputKeys.INDENT, "yes");
    t.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
    t.setOutputProperty(OutputKeys.METHOD,"xml");
    t.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
    t.transform(new DOMSource(doc), new StreamResult(System.out));
    catch (Exception e) {
         e.printStackTrace();
    System.out.println(e.getMessage());
    </pre>
    Edited by: user12185243 on Apr 6, 2013 6:38 AM
    Edited by: user12185243 on Apr 6, 2013 6:41 AM
    Edited by: user12185243 on Apr 6, 2013 6:43 AM
    Edited by: user12185243 on Apr 6, 2013 6:45 AM
    Edited by: user12185243 on Apr 6, 2013 9:00 AM

    either this way we can do this
    1)
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    <b> factory.setIgnoringElementContentWhitespace(true); </b>
    DocumentBuilder db = factory.newDocumentBuilder();
    or
    2)
    java.io.StringWriter sw = new java.io.StringWriter();
    StreamResult sr = new StreamResult(sw);
    t.transform(new DOMSource(doc), sr);
    String xml1 = sw.toString().trim();
    <b> xml1=xml1.replaceAll("\\s",""); </b>
    System.out.println(xml1.trim());

  • Replace new line from xml string

    hi,
    I am getting an input string as given below
    <div class="titleBar">               
              <h1>sssPRIVACY POLICY AND YOUR CALIFORNIA PRIVACY RIGHTS</h1>               
         </div>
         <div class="txtPod"> And I want to replace all the blank lines and the output should be like
    <div class="titleBar">
              <h1>sssPRIVACY POLICY AND YOUR CALIFORNIA PRIVACY RIGHTS</h1>
         </div>
         <div class="txtPod"> I tried replaceAll("\n",""), but that doesn't seem to work.
    Can somebody help me on this

    str = str.replaceAll("(?m)^[ \t]*\r?\n", "");

  • Missing XSD line in XML file - how to add it?

    Dear all,
    We're trying to add in the XSD information to a file generated from R/3 by a standard program, which the developers don't want to adapt, as it's used by several other programs.  We'd like to do this in XI - does anyone know how or have any experience about why this would be a bad idea?
    Many thanks in advance,
    Lisa Howdle

    Hi Lisa,
    What I understood from your question is: SAP is generating a file and you want to add few more things to that file in XI.
    If we both are on the same page then you can create a xsd or extend the current xsd with the additional fields and then can load the file and send across XI.
    If we are not on the same page then can you throw some more light on this?
    Regards,
    ---Satish

  • Error while loading XML files into scott user

    Hi All,
    I'm new to xml files. I need to load xml files into database through OWB.
    I have xml file in my local machine & am trying to load into table PO of Scott. Scott is registered as repository user.
    Followed same steps as specified in userguide.
    But, when executing the procedure ( in two ways one as just table name, and other as user.table name) it is showing the below error:
    Procedure is:(1)--with username.tablename
    begin
    wb_xml_load(
    '<OWBXMLRuntime>'||
    '<XMLSource>'||
    '<file>&&SAMPLES_DIR.sample1.xml</file>'||
    '</XMLSource>'||
    '<targets>'||
    '<target dateFormat="yyyy.MM.dd">scott.PO</target>'||
    '</targets>'||
    '</OWBXMLRuntime>'
    end;
    ERROR at line 1:
    ORA-20006: Error occurred while truncating target database object SCOTT.PO.
    Base exception: ORA-01031: insufficient privileges
    ORA-06512: at "OWBSYS.WB_XML_LOAD_F", line 12
    ORA-06512: at "OWBSYS.WB_XML_LOAD", line 4
    ORA-06512: at "SCOTT.SAMPLE1", line 3
    ORA-06512: at line 1
    Procedure is:(2) with out username
    begin
    wb_xml_load(
    '<OWBXMLRuntime>'||
    '<XMLSource>'||
    '<file>&&SAMPLES_DIR.sample1.xml</file>'||
    '</XMLSource>'||
    '<targets>'||
    '<target dateFormat="yyyy.MM.dd">PO</target>'||
    '</targets>'||
    '</OWBXMLRuntime>'
    end;
    ERROR at line 1:
    ORA-20006: Error occurred while truncating target database object PO.
    Base exception: ORA-00942: table or view does not exist
    ORA-06512: at "OWBSYS.WB_XML_LOAD_F", line 12
    ORA-06512: at "OWBSYS.WB_XML_LOAD", line 4
    ORA-06512: at line 2
    xml file:
    <ROWSET>
    <ROW>
    <ID>100</ID>
    <ORDER_DATE>2000.12.20</ORDER_DATE>
    <SHIPTO_NAME>Adrian Howard</SHIPTO_NAME>
    <SHIPTO_STREET>500 Marine World Parkway</SHIPTO_STREET>
    <SHIPTO_CITY>Redwood City</SHIPTO_CITY>
    <SHIPTO_STATE>CA</SHIPTO_STATE>
    <SHIPTO_ZIP>94065</SHIPTO_ZIP>
    </ROW>     
    </ROWSET>
    Note: Everything works fine if I create PO table in OWBSYS user and execute the procedurein OWBSYS user. OWBSYS.PO table will be loaded.
    What privileges are missing, what shouldI do if I want to execute the procedure from scott user and load the table of scott.
    Thanks in advance for the help.
    Regards,
    Joshna

    Hi Joshna,
    Please follow below steps to load xml file to oracle database.
    1.First connect to owb (Design Center) through your repository owner user (ex : REP_OWNER).
    2. Import WB_XML_LOAD procedure . and exit to repository owner.
    3. connect to owb design center through your repository user (ex : REP_USER)
    Create New mapping and drag one Constant Operator and create one attribute, paste / edit following code
    '<OWBXMLRuntime>'||
    '<XMLSource>'||
    '<file>E:\SOURCE\emp.xml</file>'||
    '</XMLSource>'||
    '<targets>'||
    '<target truncateFirst = "FALSE" dateFormat="yyyy.MM.dd">rep_user.emp</target>'||
    '</targets>'||
    '</OWBXMLRuntime>'
    4. Drag pre mapping operator and select WB_XML_LOAD procedure
    5. Connect Constant Operator attribute to pre mapping operator.
    6. Drag two dummy tables and connect source to target. (ex : drag t1 (table) tab two times and connect.
    7. Validate and deploy the mapping.
    8. grant necessary grant command to rep_owner user to rep_user user.
    (Note : target truncateFirst = "FALSE" by default truncate the table. So you have to give grant privileges
    To rep_user , select ,insert, delete privileges.
    9. Execute the mapping , and check EMP table. (Note : before loading EMP table delete all records ).
    10 . If you want more description please go through the below link
    http://download.oracle.com/docs/html/A95931_01/apf.htm
    Regards
    Venkat

  • Problem when loading xml file using sql loader

    I am trying to load data into table test_xml (xmldata XMLType)
    i have an xml file and i want whole file to be loaded into a single column
    when i use the following control file and executed from command prompt as follows
    sqlldr $1@$TWO_TASK control=$XXTOP/bin/LOAD_XML.ctl direct=true;:
    LOAD DATA
    INFILE *
    TRUNCATE INTO TABLE test_xml
    xmltype(xmldata)
    FIELDS
    ext_fname filler char(100),
    xmldata LOBFILE (ext_fname) TERMINATED BY EOF
    BEGIN DATA
    /u01/APPL/apps/apps_st/appl/xxtop/12.0.0/bin/file.xml
    the file is being loaded into table perfectly.
    unfortunatley i cant hardcode file name as file name will be changed dynamically.
    so i removed the block
    BEGIN DATA
    /u01/APPL/apps/apps_st/appl/xxtop/12.0.0/bin/file.xml
    from control file and tried to execute by giving file path from command line as follows
    sqlldr $1@$TWO_TASK control=$XXTOP/bin/LOAD_XML.ctl data=/u01/APPL/apps/apps_st/appl/xxtop/12.0.0/bin/file.xml direct=true;
    but strangely it's trying to load each line of xml file into table instead of whole file
    Please find the log of the program with error
    Loading of XML through SQL*Loader Starts
    SQL*Loader-502: unable to open data file '<?xml version="1.0"?>' for field XMLDATA table TEST_XML
    SQL*Loader-553: file not found
    SQL*Loader-509: System error: No such file or directory
    SQL*Loader-502: unable to open data file '<Root>' for field XMLDATA table TEST_XML
    SQL*Loader-553: file not found
    SQL*Loader-509: System error: No such file or directory
    SQL*Loader-502: unable to open data file '<ScriptFileType>' for field XMLDATA table TEST_XML
    SQL*Loader-553: file not found
    SQL*Loader-509: System error: No such file or directory
    SQL*Loader-502: unable to open data file '<Type>Forms</Type>' for field XMLDATA table TEST_XML
    SQL*Loader-553: file not found
    SQL*Loader-509: System error: No such file or directory
    SQL*Loader-502: unable to open data file '</ScriptFileType>' for field XMLDATA table TEST_XML
    SQL*Loader-553: file not found
    SQL*Loader-509: System error: No such file or directory
    SQL*Loader-502: unable to open data file '<ScriptFileType>' for field XMLDATA table TEST_XML
    SQL*Loader-553: file not found
    SQL*Loader-509: System error: No such file or directory
    SQL*Loader-502: unable to open data file '<Type>PLL</Type>' for field XMLDATA table TEST_XML
    SQL*Loader-553: file not found
    SQL*Loader-509: System error: No such file or directory
    SQL*Loader-502: unable to open data file '</ScriptFileType>' for field XMLDATA table TEST_XML
    SQL*Loader-553: file not found
    SQL*Loader-509: System error: No such file or directory
    SQL*Loader-502: unable to open data file '<ScriptFileType>' for field XMLDATA table TEST_XML
    please help me how can i load full xml into single column using command line without hardcoding in control file
    Edited by: 907010 on Jan 10, 2012 2:24 AM

    but strangely it's trying to load each line of xml file into table instead of whole fileNothing strange, the data parameter specifies the file containing the data to load.
    If you use the XML filename here, the control file will try to interpret each line of the XML as being separate file paths.
    The traditional approach to this is to have the filename stored in another file, say filelist.txt and use, for example :
    echo "/u01/APPL/apps/apps_st/appl/xxtop/12.0.0/bin/file.xml" > filelist.txt
    sqlldr $1@$TWO_TASK control=$XXTOP/bin/LOAD_XML.ctl data=filelist.txt direct=true;

  • Read data from xml files and  populate internal table

    Hi.
    How to read data from xml files into internal tables?
    Can u tell me the classes and methods to read xml data..
    Can u  explain it with a sample program...

    <pre>DATA itab_accontextdir TYPE TABLE OF ACCONTEXTDIR.
    DATA struct_accontextdir LIKE LINE OF itab_accontextdir.
    DATA l_o_error TYPE REF TO cx_root.
    DATA: filename type string ,
                 xmldata type xstring .
    DATA: mr      TYPE REF TO if_mr_api.
    mr = cl_mime_repository_api=>get_api( ).
    mr->get( EXPORTING  i_url     = 'SAP/PUBLIC/BC/xml_files_accontext/xml_accontextdir.xml'
                  IMPORTING  e_content = xmldata ).
    WRITE xmldata.
    TRY.
    CALL TRANSFORMATION id
          SOURCE XML xmldata
          RESULT shiva = itab_accontextdir.
      CATCH cx_root INTO l_o_error.
    ENDTRY.
    LOOP AT itab_accontextdir INTO struct_accontextdir.
        WRITE: / struct_accontextdir-context_id,
               struct_accontextdir-context_name,
               struct_accontextdir-context_type.
        NEW-LINE.
        ENDLOOP.</pre>
    <br/>
    Description:   
    In the above code snippet I am storing the data in an xml file(you know xml is used to store and transport data ) called 'xml_accontextdir.xml' that is uploaded into the MIME repository at path 'SAP/PUBLIC/BC/xml_files_accontext/xml_accontextdir.xml'.
    The below API is used to read a file in MIME repo and convert it into a string that is stored in ' xmldata'. (This is just a raw data that is got by appending the each line of  xml file).
    mr = cl_mime_repository_api=>get_api( ).
    mr->get( EXPORTING  i_url     = 'SAP/PUBLIC/BC/xml_files_accontext/xml_accontextdir.xml'
                  IMPORTING  e_content = xmldata ).
        Once the 'xmldata' string is available we use the tranformation to parse the xml string that we have got from the above API and convert it into the internal table.
    <pre>TRY.
    CALL TRANSFORMATION id
          SOURCE XML xmldata
          RESULT shiva = itab_accontextdir.
      CATCH cx_root INTO l_o_error.
    ENDTRY.</pre>
    Here the trasnsformation 'id ' is used to conververt the source xml 'xmldata' to resulting internal table itab_accontextdir, that have same structure as our xml file 'xml_accontextdir.xml'.  In the RESULT root of the xml file has to be specified. (In my the root is 'shiva'). 
    Things to be taken care:
    One of the major problem that occurs when reading the xml file is 'format not compatible with the internal table' that you are reading into internal table.  Iin order to get rid of this issue use one more tranformation to convert the data from the internal table into the xml file.    
    <pre>TRY.
          CALL TRANSFORMATION id
            SOURCE shiv = t_internal_tab
            RESULT XML xml.
        CATCH cx_root INTO l_o_error.
      ENDTRY.
      WRITE xml.
      NEW-LINE.</pre>
    <br/>
    This is the same transformation that we used above but the differnce is that the SOURCE and RESULT parameters are changed the source is now the internal table and result is *xml *string. Use xml browser that is available with the ABAP workbench to read the xml string displayed with proper indentation. In this way we get the format of xml file to be used that is compatable with the given internal table. 
    Thank you, Hope this will help you!!!
    Edited by: Shiva Prasad L on Jun 15, 2009 7:30 AM
    Edited by: Shiva Prasad L on Jun 15, 2009 11:56 AM
    Edited by: Shiva Prasad L on Jun 15, 2009 12:06 PM

  • Find and replace a line in a text  file

    Hi All,
    I wanted to read a text file , find a line and replace that line with out affecting any other lines and with out creating a new file.
    If any one of you know any API to do this work ,please throw some light

    This seems to be a question on optimal implementation of search and replace.
    For replacing text in the file itself, the sought text and replaced text must be the same length,
    as inserting a character somewhere in a file, is better done in a new file.
    You could do this with a java.io.RandomAccessFile[b].
    The new IO package [b]java.nio provides a memory mapped file which is faster.
    The following code does such patching.
    import java.io.*;
    import java.nio.*;
    import java.nio.channels.*;
    public class Patch {
        private static byte[] sought;
         private static byte[] replacement;
         private static boolean matches(MappedByteBuffer bb, int pos) {
              for (int j = 0; j < sought.length; ++j)
                   if (sought[j] != bb.get(pos + j))
                        return false;
              return true;
         private static void replace(MappedByteBuffer bb, int pos) {
              for (int j = 0; j < sought.length; ++j)
                   byte b = (j < replacement.length)? replacement[j] : (byte)' ';
                   bb.put(pos + j, b);
         private static void searchAndReplace(MappedByteBuffer bb, int sz) {
              int replacementsCount = 0;
              for (int pos = 0; pos <= sz - sought.length; ++pos)
                   if (matches(bb, pos)) {
                        replace(bb, pos);
                        pos += sought.length - 1;
                        ++replacementsCount;
              System.out.println("" + replacementsCount + " replacements done.");
        // Search for occurrences of the input pattern in the given file
        private static void patch(File f) throws IOException {
              // Open the file and then get a channel from the stream
              RandomAccessFile raf = new RandomAccessFile(f, "rw"); // "rws", "rwd"
              FileChannel fc = raf.getChannel();
              // Get the file's size and then map it into memory
              int sz = (int)fc.size();
              MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_WRITE, 0, sz);
              searchAndReplace(bb, sz);
              bb.force(); // Write back to file, like "flush()"
              // Close the channel and the stream
              raf.close();
        public static void main(String[] args) {
              if (args.length == 0)
                   args = new String[] { "row ", "item", "2.xml" };
              if (args.length < 3) {
                   System.err.println("Usage: java Patch sought replacement file...");
                   return;
              sought = args[0].getBytes();
              replacement = args[1].getBytes();
              if (sought.length != replacement.length) {
                   // Better build-in some support for padding with blanks.
                   System.err.println("Usage: sought (" + args[0] + ") and replacement (" + args[1] + ") must have same length");
                   return;
              for (int i = 2; i < args.length; i++) {
                   File f = new File(args);
                   try {
                        patch(f);
                   } catch (IOException x) {
                        System.err.println(f + ": " + x);

  • XSLT mapping code to replace ns1: tag as plm: in XML file in PI mapping

    Hi
    I am sending XML file to HTTP server as below format
    <?xml version="1.0" encoding="UTF-8" ?>
       - <ns1:Responses xmlns:ns1="http://">
    -    <ns1:Response Application="SAP">
        <ns1:field1>12345</ns1:field1>
        <ns1:field2>abc</ns1:field2>
       - <ns1:Items>
        <ns1:doc></ns1:doc>
      </ns1:Items>
      </ns1:Response>
      </ns1:Responses>
    i hve to replace <ns1: as <plm:, i could able to delete <ns1: tag uisng XSLT mapping(in sdn), but i dont know how to add tag with <plm:
    Hi XSLT experts/if any has come across this requirment, please send XSLT code to add tag in XML.
    Regards,
    Rajesh

    No need for XSLT, just use the XMLAnonymizerBean module in your receiver communication channel.
    http://help.sap.com/saphelp_nw70/helpdata/EN/45/d169186a29570ae10000000a114a6b/frameset.htm
    /people/stefan.grube/blog/2007/02/02/remove-namespace-prefix-or-change-xml-encoding-with-the-xmlanonymizerbean
    If your receiver CC cannot process modules (ABAP receiver, for example), in your XSLT just define the target namespace with the desired prefix.
    Regards,
    Henrique.

  • Download created XML File in batch mode // Parse XML file into single lines

    Hello!
    I upload a CSV file and based on that CSV file I create an XML "object". First I uploaded and downloaded it via gui frontendclass, but as it has to be run in a batch in the night I need to upload and download the data via OPEN DATASET.
    The import and transformation of the CSV file works fine, also the transfer into an itab with the same structure as a CSV line is ok. I also create the XML file, which could be downloaded easily with gui-download but it is not permittet.
    Import of data: I scan the folder and get the filenames into a itab, I loop over that itab and read the single files like this:
         OPEN DATASET ls_convert_batch FOR INPUT IN TEXT MODE ENCODING DEFAULT.
          CLEAR tab.
          IF sy-subrc = 0.
            DO.
              READ DATASET ls_convert_batch INTO line.
              IF sy-subrc <> 0.
                EXIT.
              ELSE.
                CLEAR tmptab.
                SPLIT line AT ';' INTO  tmptab-product
                                        tmptab-contract
                                        tmptab-extagent.
                APPEND tmptab TO tab.
              ENDIF.
            ENDDO.
          ENDIF.
    The XML file has a strucutre like
    <file>
    - <file formant_no="1.1" format_date="02.10.2003">
      <status>V</status>
      <number>001001025</numbner>
      <name>Schmeisser,Christof</name>
    - <details>
    -    <detail>
             <contract>00000003494</contract>
             <name>Schmeisser, Christof</name>
             <invoice_no>000000003840</invoice_no>
             <due_date>20100601</due_date>
             <amount>140,00</amount>
         </detail>
    -    <detail>
             <contract>00000003495</contract>
             <name>Schmeisser, Christof</name>
             <invoice_no>000000003841</invoice_no>
             <due_date>20100601</due_date>
             <amount>130,00</amount>
         </detail>
    - </details>
    <elements>2</elements>
    <amount_overall>270</amount_overall>
    </file>
    At the moment I download it like this:
    CALL METHOD cl_gui_frontend_services=>gui_download
            EXPORTING
              bin_filesize = l_xml_size
              filename     = filename
              filetype     = 'BIN'
    *        CONFIRM_OVERWRITE = '0'
            CHANGING
              data_tab     = l_xml_table
            EXCEPTIONS
              OTHERS       = 24.
          IF sy-subrc <> 0.
            MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                       WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
          ELSEIF sy-subrc = 0.
            lv_create_counter = lv_create_counter + 1.
          ENDIF.
    But I need to download it via OPEN TRANSFER CLOSE Dataset as it has to run in batch mode.
    Anyone has an idea? I am really desperate here. One idea would be to parse the single lines into a string and then create the XML file line by line as text and save it with ending XML, should work. But I don't know how!
    Thank you very much in advance,
    kind regards from Tallinn, Estonia,
    Christof!
    Edited by: Christof Schmeisser on Nov 25, 2010 7:51 PM
    I edited the heading, would be too general and missleading!

    Tipos Pools
    TYPE-POOLS: ixml.
    CLASS cl_ixml DEFINITION LOAD.
    TYPES: BEGIN OF xml_node_type,
             node   TYPE char50,
             vlnode TYPE string,
           END OF xml_node_type,
           BEGIN OF xml_line_type,
             data(256) TYPE x,
           END OF xml_line_type.
    Tabelas Internas
    DATA: ti_xml_node        TYPE TABLE OF xml_node_type.
    Variáveis TYPE REF
    *Type REF para utilizar no XML
    DATA: ixml_type             TYPE REF TO if_ixml,
          streamfactory_type    TYPE REF TO if_ixml_stream_factory,
          ostream_type          TYPE REF TO if_ixml_ostream,
          istream_type          TYPE REF TO if_ixml_istream,
          parser_type           TYPE REF TO if_ixml_parser,
          renderer_type         TYPE REF TO if_ixml_renderer,
          document_type         TYPE REF TO if_ixml_document,
          encoding_type         TYPE REF TO if_ixml_encoding,
          node_type             TYPE REF TO if_ixml_node,
          element_dtrans_type   TYPE REF TO if_ixml_element,
          element_xml_in_type   TYPE REF TO if_ixml_element,
          element_roteiros_type TYPE REF TO if_ixml_element,
          element_roteiro_type  TYPE REF TO if_ixml_element,
          element_vias_type     TYPE REF TO if_ixml_element,
          element_via_type      TYPE REF TO if_ixml_element,
          element_dummy_type    TYPE REF TO if_ixml_element,
          gw_xml_node           TYPE TABLE OF xml_node_type,
          gw_xml_node_ret       TYPE TABLE OF xml_node_type,
          gw_xml_node_err       TYPE TABLE OF xml_node_type,
          gw_xml_node_xml       TYPE TABLE OF xml_node_type,
          gw_xml_table          TYPE TABLE OF xml_line_type,
          gw_xml_table2         TYPE TABLE OF xml_line_type,
          gs_xml_node           TYPE xml_node_type,  "WA para leitura do xml
          gs_xml_node_ret       TYPE xml_node_type,  "WA para leitura do xml retorno
          gs_xml_node_err       TYPE xml_node_type,  "WA para leitura do xml erro
          gs_xml_node_xml       TYPE xml_node_type,  "WA para leitura do xml info sucesso
          gs_xml_table2         TYPE xml_line_type.  "WA para importar xml
    Variáveis do Programa
    DATA: l_value              TYPE string,
          l_rc                 TYPE i,
          l_xml_size           TYPE i,
          cod_cartaorepom      TYPE char20 VALUE '123456789',
          v_caminho_exp        TYPE string VALUE 'C:TEMP',
          v_salvaarquivo       TYPE string,
          v_nomearquivo        TYPE string,
          w_nodetext           TYPE string,
          v_roteiros           TYPE string,
          v_roteiro            TYPE string,
          v_roteiro_codigo     TYPE string,
          v_percurso_codigo    TYPE string,
          v_percurso_descricao TYPE string,
          v_cidade_origem      TYPE string,
          v_estado_origem      TYPE string,
          v_cidade_destino     TYPE string,
          v_estado_destino     TYPE string,
          v_transporte_tipo    TYPE string,
          v_cartao_taxa        TYPE string,
          v_cobra_taxa         TYPE string.
    Constants
    CONSTANTS: cc_39         TYPE string VALUE '39', " Numero 39.
               cc_dt_trans   TYPE string VALUE 'data_transfer'," document_type(name)
               cc_metodo_cod TYPE string VALUE 'metodo_codigo'," document_type(name)
               cc_xml_in     TYPE string VALUE 'xml_in'," document_type(name)
               cc_ct_tx_ativ TYPE string VALUE 'cartao_taxa_ativacao'," document_type(name)
               cc_cartao     TYPE string VALUE 'cartao', " Parâmetro Perform.
               cc_xml        TYPE string VALUE '.XML'," extenção
               cc_bin        TYPE char10 VALUE 'BIN'." filetype
    START-OF-SELECTION.
      PERFORM yf_inicia_criacao_xml USING cc_39.
      element_roteiro_type  = document_type->create_simple_element(
                     name   = cc_ct_tx_ativ
                     parent = element_xml_in_type  ).
      PERFORM yf_dummy_roteiro USING cod_cartaorepom cc_cartao.
      PERFORM yf_finaliza_xml.
      PERFORM yf_exporta_xml USING v_caminho_exp.
      PERFORM yf_convert_xml_to_itab TABLES gw_xml_node_ret
                                      USING v_salvaarquivo.
    END-OF-SELECTION.
    *&      Form  yf_inicia_criacao_xml
          text
         -->VALUE(P_0783)  text
    FORM yf_inicia_criacao_xml USING value(p_0783).
      DATA: s_encoding_type TYPE string VALUE 'ISO-8859-1'.
    Cria o ixml factory
      ixml_type = cl_ixml=>create( ).
    *Cria o objeto com modelo
      document_type = ixml_type->create_document( ).
    *Cria o cabeçalho encoding="iso-8859-1"
      encoding_type = ixml_type->create_encoding( byte_order = 0
                        character_set = s_encoding_type ).
    *Cria o root "DATA_TRANSFER"
      element_dtrans_type = document_type->create_simple_element(
                    name  = cc_dt_trans
                  parent  = document_type ).
    *Cria o node "METODO_CODIGO" e preenche com um valor passado no L_VALUE
      l_value = p_0783.
      CONDENSE l_value.
      element_dummy_type = document_type->create_simple_element(
                    name = cc_metodo_cod
                   value = l_value
                  parent = element_dtrans_type ).
    *Cria o node "XML_IN"
      element_xml_in_type   = document_type->create_simple_element(
                  name   = cc_xml_in
                  parent = element_dtrans_type  ).
    ENDFORM.                    " yf_inicia_criacao_xml
    *&      Form  yf_dummy_roteiro
          text
         -->VALUE(P_0996)  text
         -->VALUE(P_0997)  text
    FORM yf_dummy_roteiro USING value(p_0996)
                                value(p_0997).
      l_value  = p_0996.
      CONDENSE l_value.
      element_dummy_type = document_type->create_simple_element(
                    name = p_0997
                   value = l_value
                  parent = element_roteiro_type ).
    ENDFORM.                    " yf_dummy_roteiro
    *&      Form  yf_finaliza_xml
          text
    FORM yf_finaliza_xml.
    *Cria o stream factory
      streamfactory_type = ixml_type->create_stream_factory( ).
    *Conecta a internal table de XML com o stream factory
      ostream_type = streamfactory_type->create_ostream_itable( table = gw_xml_table  ).
      CALL METHOD ostream_type->set_encoding
        EXPORTING
          encoding = encoding_type.
    *Rendering the document
      renderer_type = ixml_type->create_renderer( ostream  = ostream_type
                                            document = document_type ).
      l_rc = renderer_type->render( ).
    *Salva o documento XML
      l_xml_size = ostream_type->get_num_written_raw( ).
    ENDFORM.                    " yf_finaliza_xml
    *&      Form  yf_exporta_xml
          text
         -->VALUE(P_0783)  text
    FORM yf_exporta_xml USING value(p_0783).
      CONCATENATE cod_cartaorepom
                  sy-datum
                  sy-uzeit
                  cc_xml
             INTO v_nomearquivo.
      CONCATENATE p_0783
                  v_nomearquivo
             INTO v_salvaarquivo.
      TRANSLATE v_nomearquivo TO UPPER CASE.
    *Exporta o XML
      CALL METHOD cl_gui_frontend_services=>gui_download
        EXPORTING
          bin_filesize = l_xml_size
          filename     = v_salvaarquivo
          filetype     = cc_bin
        CHANGING
          data_tab     = gw_xml_table
        EXCEPTIONS
          OTHERS       = 24.
      IF sy-subrc = 0.
       PERFORM yf_sapgui_progress_indicator USING cc_msg_xml_ok.
      ELSE.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " yf_exporta_xml
    *&      Form  yf_convert_xml_to_itab
          text
         -->P_GW_XML_NODE_RET  text
         -->P_FILENAME         text
    FORM yf_convert_xml_to_itab  TABLES p_gw_xml_node_ret LIKE gw_xml_node
                                USING  p_filename.
      DATA l_count.
      ixml_type = cl_ixml=>create( ).
    Now Create Stream Factory
      streamfactory_type = ixml_type->create_stream_factory( ).
      CALL METHOD cl_gui_frontend_services=>gui_upload
        EXPORTING
          filename   = p_filename
          filetype   = cc_bin
        IMPORTING
          filelength = l_xml_size
        CHANGING
          data_tab   = gw_xml_table2
        EXCEPTIONS
          OTHERS     = 19.
      IF sy-subrc = 0.
        istream_type = streamfactory_type->create_istream_itable( table = gw_xml_table2
                                                            size  = l_xml_size ).
        document_type = ixml_type->create_document( ).
        parser_type = ixml_type->create_parser( stream_factory = streamfactory_type
                                         istream         = istream_type
                                         document        = document_type ).
        IF parser_type->parse( ) NE 0.
          IF parser_type->num_errors( ) NE 0.
            l_count = parser_type->num_errors( ).
          ENDIF.
        ENDIF.
        CALL METHOD istream_type->close( ).
        CLEAR istream_type.
        node_type = document_type.
        PERFORM yf_get_data USING node_type.
        p_gw_xml_node_ret[] = gw_xml_node[].
        CLEAR gw_xml_node[].
      ENDIF.
    ENDFORM.                    " yf_convert_xml_to_itab
    *&      Form  yf_get_data
          text
         -->VALUE(X_NODE)  text
    FORM yf_get_data    USING value(x_node) TYPE REF TO if_ixml_node.
      DATA: indent      TYPE i.
      DATA: ptext       TYPE REF TO if_ixml_text.
      DATA: string      TYPE string.
      DATA: temp_string(100).
      CASE x_node->get_type( ).
        WHEN if_ixml_node=>co_node_element.
          string = x_node->get_name( ).
          w_nodetext = string.
          CLEAR string.
          string = x_node->get_value( ).
          IF NOT w_nodetext IS INITIAL OR
             NOT string IS INITIAL.
            gs_xml_node-node   = w_nodetext.
            gs_xml_node-vlnode = string.
            IF NOT gs_xml_node-vlnode IS INITIAL.
              APPEND gs_xml_node TO gw_xml_node.
              CLEAR  gs_xml_node.
            ENDIF.
          ENDIF.
      ENDCASE.
    Get the next child
      x_node = x_node->get_first_child( ).
    Recurse
      WHILE NOT x_node IS INITIAL.
        PERFORM yf_get_data USING x_node.
        x_node = x_node->get_next( ).
      ENDWHILE.
    ENDFORM.                    "yf_get_data

  • How to set SAXParser at command-line interface to create a large XML file

    Hi,
    I am trying to create a large XML file (more than 50 MB) by selecting from Oracle database but failed because of "out of memory" error. According to "Oracle XML Developer Guide", we should use SAXParser to parsing a large XML file. But there is no example to show how to set SAXParser at command-line
    Following is what I use to get xml files. It works only when the file is small.
    java OracleXML getXML -DateFormat -withDTD -rowsetTag PO_HDR -conn
    "jdbc:oracle:oci8:@server_name" -user "ID/password" "select * from table_name"
    When I set SAXParser at the way below,
    java oracle.xml.parser.v2.SAXParser OracleXML getXML -DateFormat -withDTD -rowsetTag PO_HDR -conn
    "jdbc:oracle:oci8:@server_name" -user "ID/password" "select * from table_name"
    it failed with the error message: "In class oracle.xml.parser.v2.SAXParser: void main(String argv[]) is not defined"
    Does anyone know how to solve the problem? I'll be appreciated very much for your help.
    Yi

    here are my ideas.
    register the xml schema.
    using xmldom, generate the desired xml output and return as xmltype.
    then you can use something like this to check.
    declare
    xmldoc xmltype ;
    begin
       -- populate xmldoc from you xmldom function
       -- validate against XML schema
       xmldoc.isSchemaValid(schema_url, root_element);
       if xmldoc.isSchemaValid = 1 then
            --valid schema
       else
            --invalid
       end if;
    end

  • Add an extra line in the output xml file

    Dear All
    My scenarios is idoc to xml file.For the resultant xml file i have to append a line  <?Test Line?> after
    <?xml version="1.0" encoding="UTF-8" ?>  while passing it to  legacy system ?
    How generate such a xml file in xi?
    Any help would be appreciated
    Thanks and regards
    uday

    Dear All
    my requirement is to generate an xml file which looks similar to
    <?xml version="1.0" encoding="UTF-8"?>
    <?TestLine?>
    <test_mt>
    <field1>123</field1>
    <field2>234</field2>
    </test_mt>
    how to add <?TestLine?>  tag?
    Hi shabrasish and rajashekar
    i am new to java and xslt mapping can you guide me  or give me links which are similar to my requirement how to proceed with this kind of mapping
    thanks
    uday

Maybe you are looking for