Parsing xml payload and edit it

Hi
I am trying to parse xml payload in sender side.I have inserted a stateless session bean before " local ejbs call sap adapter".But changes made to string are not reflected in xml file.The code written in ejb is as follows
package com.cts.xi;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.ejb.CreateException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import com.sap.aii.af.mp.module.Module;
import com.sap.aii.af.mp.module.ModuleContext;
import com.sap.aii.af.mp.module.ModuleData;
import com.sap.aii.af.ra.ms.api.Message;
import com.sap.aii.af.ra.ms.api.PayloadFormatException;
import com.sap.aii.af.ra.ms.api.XMLPayload;
@ejbLocal <{com.cts.xi.EjbLocal}>
@ejbLocalHome <{com.cts.xi.EjbLocalHome}>
@stateless
@transactionType Container
public class EjbBean implements SessionBean, Module {
     public void ejbRemove() {
     public void ejbActivate() {
     public void ejbPassivate() {
     public void setSessionContext(SessionContext context) {
          myContext = context;
     private SessionContext myContext;
Create Method.
     public void ejbCreate() throws CreateException {
          // TODO : Implement
     /* (non-Javadoc)
@see com.sap.aii.af.mp.module.Module#process(com.sap.aii.af.mp.module.ModuleContext, com.sap.aii.af.mp.module.ModuleData)
     public ModuleData process(ModuleContext mc, ModuleData md) {
          // TODO Auto-generated method stub
          Message msg = (Message) md.getPrincipalData();
          XMLPayload pl = msg.getDocument();
          String str = null;
          String str1 = null;
          int m = 0;
          str = new String(pl.getContent());
          /*int[] ra = null;
          for (int i = 0; i < 4; i++) {
               ra<i> = Integer.parseInt(mc.getContextData("rate"));
          try {
               File f1 = new File("
pciib04530
USERS
piyush
test1.xml");
               FileOutputStream fout1;
               fout1 = new FileOutputStream(f1);
               fout1.write(str.getBytes());
               fout1.close();
          } catch (RuntimeException e2) {
               // TODO Auto-generated catch block
               e2.printStackTrace();
          } catch (FileNotFoundException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
          } catch (IOException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
          try {
               Document doc = DocumentHelper.parseText(str);
               Element root = doc.getRootElement();
               str1 = traverseXML(root, str1,m);
          } catch (DocumentException e3) {
               // TODO Auto-generated catch block
               e3.printStackTrace();
          try {
               File f6 = new File("
pciib04530
USERS
piyush
test6.txt");
               FileOutputStream fout6;
               fout6 = new FileOutputStream(f6);
               //fout2.write(rt.getBytes());
               //fout2.write(str1.getBytes());
               //fout2.write(str2.getBytes());
               //fout2.write(str3.getBytes());
               fout6.write(str1.getBytes());
               fout6.close();
          } catch (FileNotFoundException e4) {
               // TODO Auto-generated catch block
               e4.printStackTrace();
          } catch (IOException e4) {
               // TODO Auto-generated catch block
               e4.printStackTrace();
          try {
               pl.setText(str);
          } catch (IOException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
          try {
               msg.setDocument(pl);
          } catch (PayloadFormatException e1) {
               // TODO Auto-generated catch block
               e1.printStackTrace();
          md.setPrincipalData(msg);
          return md;
@param root
@param str1
     private String traverseXML(Element e, String str1,int m) {
          // TODO Auto-generated method stub
          int spc = 0;
          String tmp = null;
          String tmp1 = null;
          tmp1 = str1;
          tmp = e.getName();
          String tmp3 = new String("SIPIR");
          if (tmp3.equals(e.getName())) {
               int l = Integer.parseInt(e.getStringValue());
               e.setName("SI");
                int k = l * 3;
               m++;
          str1 += tmp;
          /*for(int i=0;i<e.nodeCount();i++){
               Element e1=e.elements().get(i);
          for (int j = 0; j < e.attributeCount(); j++) {
               str1 += e.attribute(j).getName();
               str1 += e.attribute(j).getData();
          for (int i = 0; i < e.elements().size(); i++) {
               Element e1 = (Element) e.elements().get(i);
               spc += 3;
               traverseXML(e1, str1,m);
               spc -= 3;
          return str1;
Thanking you in advance.
Regards
piyush

xml or plist , just the extension differs.(Both are Extended Markup Language).
If u want to edit it manually - u can use property list editor (which is in XCode )
or u can open with dashcode , which can be edited easily.
If ur question was to edit dynamically.
U can do that with write to file functionality.
For example u may check this.
http://www.iphonedevsdk.com/forum/iphone-sdk-development/1613-read-write-create- data-files.html

Similar Messages

  • How to parse XML Column and insert values into a table

    Hello,
    I am working on a simple project to demonstrate how to load and extract XML using SQL, I have already made a table that contains a column of XMLTYPE and loaded an XML file into it (code below)
    create or replace directory XMLSRC as 'C:\XMLSRC';
    drop table Inventory;
    create table Inventory(Inv XMLTYPE);
    INSERT INTO Inventory VALUES (XMLTYPE(bfilename('XMLSRC', 'Inventory.xml'),nls_charset_id('AL32UTF')));
    select * from Inventory;
    I now however need to get the XML data back out of that and loaded into a new table. Troubleshooting guides I have read online seem to only be dealing with parsing an external XML document and loading it into a table, and not what I need to do which is parse a column of XML data and load that into a table. The project trivial with simple tables containing only 3 columns.
    The table that needs to be loaded is as follows:
    create table InventoryOut(PartNumber Number(10), QTY Number(10), WhLocation varchar2(500));
    The XML document is as follows:
    <?xml version="1.0" encoding="UTF-8"?>
    <dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Inventory.xsd" generated="2012-04-09T17:36:30">
    <Inventory>
    <PartNumber>101</PartNumber>
    <QTY>12</QTY>
    <WhLocation>WA</WhLocation>
    </Inventory>
    </dataroot>
    Thank you for any help you can offer.

    First of all, thank you for your help!! Still stunned that you actually took the time to write out an eample using my tables/names/etc. Thank you!!
    Attached is the code, there seems to be an issue with referencing the other table, Inventory.Inv, I checked and that table and the Inv column are showing up in the database so I am not sure why it is having issues locating them, take a look at the code I wrote as well as the output (*I included the real version number for you this time :)
    EDIT: In your code right here:
    select xt.*
    3 from Inventory inve,
    4 XMLTable('/dataroot/Inventory'
    5 PASSING inve.Inv
    I think is where I am messing it up, perhaps not understanding fully what is going on, as you write "Inventory inve" and "inve.Inv" ---- Is inve a keyword that I am just not familiar with? I think this is where the issues lies in my code.
    END EDIT
    EDIT2: Well that looks like it was it, changed that to how you have it and it now works!!! Could you please explain what that few lines is doing, and what the xt.* and inve are doing? Thanks again!!!
    END EDIT2
    drop table InventoryOut;
    create table InventoryOut (PartNumber number(10), QTY number(10), WhLocation varchar2(500));
    insert into InventoryOut (PartNumber, QTY, WhLocation)
    select xt.*
    from Inventory Inv,
    XMLTable('/dataroot/Inventory'
    PASSING Inventory.Inv COLUMNS
    PartNumber number path 'PartNumber',
    QTY number path 'QTY',
    WhLocation path 'WhLocation')xt;
    select * from InventoryOut;
    select * from v$version;
    table INVENTORYOUT dropped.
    table INVENTORYOUT created.
    Error starting at line 4 in command:
    insert into InventoryOut (PartNumber, QTY, WhLocation)
    select xt.*
    from Inventory Inv,
    XMLTable('/dataroot/Inventory'
    PASSING Inventory.Inv COLUMNS
    PartNumber number path 'PartNumber',
    QTY number path 'QTY',
    WhLocation path 'WhLocation')xt
    Error at Command Line:8 Column:12
    Error report:
    SQL Error: ORA-00904: "INVENTORY"."INV": invalid identifier
    00904. 00000 - "%s: invalid identifier"
    *Cause:   
    *Action:
    PARTNUMBER QTY WHLOCATION
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE     11.2.0.1.0     Production
    TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    If this helps here is the code and output for the creation of the Inventory table itself:
    create or replace directory XMLSRC as 'C:\XMLSRC';
    drop table Inventory;
    create table Inventory(Inv XMLTYPE);
    INSERT INTO Inventory VALUES (XMLTYPE(bfilename('XMLSRC', 'Inventory.xml'),nls_charset_id('AL32UTF')));
    select * from Inventory;
    directory XMLSRC created.
    table INVENTORY dropped.
    table INVENTORY created.
    1 rows inserted.
    INV
    <?xml version="1.0" encoding="WINDOWS-1252"?>
    <dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Inventory.xsd" generated="2012-04-09T17:36:30">
    <Inventory>
    <PartNumber>101</PartNumber>
    <QTY>12</QTY>
    <WhLocation>WA</WhLocation>
    </Inventory>
    </dataroot>
    Thanks again for your help so far! Hope we can get this working :)
    Edited by: 926502 on Apr 11, 2012 2:47 PM
    Edited by: 926502 on Apr 11, 2012 2:49 PM
    Edited by: 926502 on Apr 11, 2012 2:54 PM
    Edited by: 926502 on Apr 11, 2012 2:54 PM
    Updated issue to solved - Edited by: 926502 on Apr 11, 2012 2:55 PM

  • Script for parsing xml data and inserting in DB

    Thank you for reading.
    I have the following example XML in an XML file. I need to write a script that can insert this data into an Oracle table. The table does not have primary keys. The data just needs to be inserted.
    I do not have xsd file in this scenario. Please suggest how to modify Method 1 https://community.oracle.com/thread/1115266?tstart=0 mentioned so that I can call the XML mentioned below and insert into a table
    Method 1
    Create or replace procedure parse_xml is 
      l_bfile   BFILE; 
      l_clob    CLOB; 
      l_parser  dbms_xmlparser.Parser; 
      l_doc     dbms_xmldom.DOMDocument; 
      l_nl      dbms_xmldom.DOMNodeList; 
      l_n       dbms_xmldom.DOMNode; 
      l_file      dbms_xmldom.DOMNodeList; 
      l_filen       dbms_xmldom.DOMNode; 
      lv_value VARCHAR2(1000); 
       l_ch      dbms_xmldom.DOMNode; 
    l_partname varchar2(100); 
    l_filename varchar2(1000); 
      l_temp    VARCHAR2(1000); 
      TYPE tab_type IS TABLE OF tab_software_parts%ROWTYPE; 
      t_tab  tab_type := tab_type(); 
    BEGIN 
      l_bfile := BFileName('DIR1', 'SoftwareParts.xml'); 
      dbms_lob.createtemporary(l_clob, cache=>FALSE); 
      dbms_lob.open(l_bfile, dbms_lob.lob_readonly); 
      dbms_lob.loadFromFile(dest_lob => l_clob,    src_lob  => l_bfile,    amount   => dbms_lob.getLength(l_bfile)); 
      dbms_lob.close(l_bfile);  
      dbms_session.set_nls('NLS_DATE_FORMAT','''DD-MON-YYYY'''); 
      l_parser := dbms_xmlparser.newParser; 
      dbms_xmlparser.parseClob(l_parser, l_clob); 
      l_doc := dbms_xmlparser.getDocument(l_parser); 
        dbms_lob.freetemporary(l_clob); 
      dbms_xmlparser.freeParser(l_parser); 
      l_nl := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'/PartDetails/Part'); 
        FOR cur_emp IN 0 .. dbms_xmldom.getLength(l_nl) - 1 LOOP 
        l_n := dbms_xmldom.item(l_nl, cur_emp); 
        t_tab.extend; 
        dbms_xslprocessor.valueOf(l_n,'Name/text()',l_partname); 
        t_tab(t_tab.last).partname := l_partname; 
        l_file := dbms_xslprocessor.selectNodes(l_n,'Files/FileName'); 
        FOR cur_ch IN 0 .. dbms_xmldom.getLength(l_file) - 1 LOOP 
          l_ch := dbms_xmldom.item(l_file, cur_ch); 
          lv_value := dbms_xmldom.getnodevalue(dbms_xmldom.getfirstchild(l_ch)); 
          if t_tab(t_tab.last).partname is null then t_tab(t_tab.last).partname := l_partname; end if; 
          t_tab(t_tab.last).filename := lv_value; 
        t_tab.extend; 
       END LOOP; 
       END LOOP; 
        t_tab.delete(t_tab.last); 
      FOR cur_emp IN t_tab.first .. t_tab.last LOOP 
      if t_tab(cur_emp).partname is not null and  t_tab(cur_emp).filename is not null then 
        INSERT INTO tab_software_parts 
        VALUES 
        (t_tab(cur_emp).partname, t_tab(cur_emp).filename); 
        end if; 
      END LOOP; 
      COMMIT; 
      dbms_xmldom.freeDocument(l_doc); 
    EXCEPTION 
      WHEN OTHERS THEN 
        dbms_lob.freetemporary(l_clob); 
        dbms_xmlparser.freeParser(l_parser); 
        dbms_xmldom.freeDocument(l_doc); 
    END; 
    <TWObject className="TWObject">
      <array size="240">
        <item>
          <variable type="QuestionDetail">
            <questionId type="String"><![CDATA[30]]></questionId>
            <questionType type="questionType"><![CDATA[COUNTRY]]></questionType>
            <country type="String"><![CDATA[GB]]></country>
            <questionText type="String"><![CDATA[Please indicate]]></questionText>
            <optionType type="String"><![CDATA[RadioButton]]></optionType>
            <answerOptions type="String[]">
              <item><![CDATA[Yes]]></item>
              <item><![CDATA[No]]></item>
            </answerOptions>
            <ruleId type="String"><![CDATA[CRP_GB001]]></ruleId>
            <parentQuestionId type="String"></parentQuestionId>
            <parentQuestionResp type="String"></parentQuestionResp>
          </variable>
        </item>
        <item>
          <variable type="QuestionDetail">
            <questionId type="String"><![CDATA[40]]></questionId>
            <questionType type="questionType"><![CDATA[COUNTRY]]></questionType>
            <country type="String"><![CDATA[DE]]></country>
            <questionText type="String"><![CDATA[Please indicate]]></questionText>
            <optionType type="String"><![CDATA[RadioButton]]></optionType>
            <answerOptions type="String[]">
              <item><![CDATA[Yes]]></item>
              <item><![CDATA[No]]></item>
            </answerOptions>
            <ruleId type="String"><![CDATA[CRP_Q0001]]></ruleId>
            <parentQuestionId type="String"></parentQuestionId>
            <parentQuestionResp type="String"></parentQuestionResp>
          </variable>
        </item>
      </array>
    </TWObject>

    Reposted as
    Script to parse XML data into Oracle DB

  • Parse xml file and extract tags (not well formed)

    im writing an xml editor and i would like to extract tags from a string of xml. And the string doesnt have to be well formed xml.
    An example "</a><b asd="kjkj"></b>"
    Output
    end tag (a)
    start tag (b)
    end tag (b)
    Sax nor stax does the job since they want well formed document. and i dont want to write a parser myself.
    any suggestions

    im writing an xml editor and i would like to extract
    tags from a string of xml. And the string doesnt have
    to be well formed xml.Then you aren't writing an XML editor. And as you observe, existing parsers don't work for you because they are don't have the requirement to process garbage. Where did you get that requirement from, anyway?

  • Parse XML file and extract data

    I'd like to parse an XML file and get some data extracted as columns.
    Input file country.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <MAS Action="Insert">
    <Country ObjectId="100000000000000009" VersionId="8"><Id>1</Id><NlTexts><Name Language="de">Land1</Name><Name Language="en">Country1</Name></NlTexts></Country>
    <Country ObjectId="100000000000000033" VersionId="2"><Id>2</Id><NlTexts><Name Language="de">Land2</Name><Name Language="en">Country1</Name></NlTexts></Country>
    </MAS>
    I'd like to parse the xmlfile in order to get the following output
    Required result:
    col1        col2           col3
    1            Land1        Country1
    2            Land2        Country2
    or alternatively
    col1  col2      
    1            Land1      
    1            Country1
    2            Land2      
    2            Country2
    I tried extract-function
    select extract((XMLTYPE(BFILENAME('XML_DAT_DIR', 'country.xml'),
               NLS_CHARSET_ID('AL32UTF8'))) , '/*/*/Id') as "xdata"
    from dual;
    xdata
    <Id>1</Id><Id>2</Id>
    and XMLTABLE (but how can I add the countries now)
    SELECT *
        FROM XMLTABLE('/*/*/Id'
               PASSING XMLTYPE(BFILENAME('XML_DAT_DIR', 'country.xml'),
               NLS_CHARSET_ID('AL32UTF8'))
    COLUMN_VALUE
    <Id>1</Id>
    <Id>2</Id>
    DB version 11.2.0.3 on Windows 64bit
    Thanks,
    Tim

    Here are a few examples.
    For your required output :
    SELECT *
    FROM XMLTable(
           '/MAS/Country'
           passing XMLType(bfilename('TEST_DIR', 'country.xml'), nls_charset_id('AL32UTF8'))
           columns col1 number       path 'Id'
                 , col2 varchar2(30) path 'NlTexts/Name[1]'
                 , col3 varchar2(30) path 'NlTexts/Name[2]'
    or, if the Language attribute is significant :
    SELECT *
    FROM XMLTable(
           '/MAS/Country'
           passing XMLType(bfilename('TEST_DIR', 'country.xml'), nls_charset_id('AL32UTF8'))
           columns col1 number       path 'Id'
                 , col2 varchar2(30) path 'NlTexts/Name[@Language="de"]'
                 , col3 varchar2(30) path 'NlTexts/Name[@Language="en"]'
    For your alternate output :
    SELECT x1.col1
         , x2.col2
         --, x2.col3
    FROM XMLTable(
           '/MAS/Country'
           passing XMLType(bfilename('TEST_DIR', 'country.xml'), nls_charset_id('AL32UTF8'))
           columns col1  number  path 'Id'
                 , names xmltype path 'NlTexts/Name'
         ) x1
       , XMLTable(
           '/Name'
           passing x1.names
           columns col2 varchar2(30) path '.'
                 --, col3 for ordinality
         ) x2
    (uncomment col3 to see what it does)
    or, in a shorter way :
    SELECT *
    FROM XMLTable(
           'for $i in /MAS/Country
              , $j in $i/NlTexts/Name
            return element r { $i/Id, $j }'
           passing XMLType(bfilename('TEST_DIR', 'country.xml'), nls_charset_id('AL32UTF8'))
           columns col1 number       path 'Id'
                 , col2 varchar2(30) path 'Name'

  • Parse xml data and insert into database

    Hi Friends,
    I have an xml document which needs to be parsed and the data need to be inserted into an oracle database table.
    Please tell me which will be the easiest and optimal way of doing this.
    Thanks,
    Achayan

    Take a look at the JDOM xml parsing library - google for JDOM download or something.
    This will allow you to build an object representation of the XML doc, from which you can then extract the data.
    J

  • Weblogic-ejb-jar.xml generation and editing question with JEE5 / EJB3

    Since EJBGen only works with EJB 2.1, is there a way to auto-generate weblogic-ejb-jar.xml when using a JEE5 ejb module?
    In the tooling like OEPE 11g, an EJB3 project will generate an empty deployment descriptor weblogic-ejb-jar.xml file if you mark it that way in the wizard, but it doesn't populate it with any values.
    Is the weblogic-ejb-jar.xml file is created/edited by hand, do the settings like this example still work or even make sense given the changes in the spec between 2.1 and 3.0?
    <weblogic-enterprise-bean>
    <ejb-name>HelloUser</ejb-name>
    <stateless-session-descriptor>
    <pool>
    <max-beans-in-free-pool>50</max-beans-in-free-pool>
    <initial-beans-in-free-pool>10</initial-beans-in-free-pool>
    </pool>
    <stateless-clustering>
    <home-is-clusterable>True</home-is-clusterable>
    <home-load-algorithm>round-robin</home-load-algorithm>
    <stateless-bean-is-clusterable>True</stateless-bean-is-clusterable>
    <stateless-bean-load-algorithm>round-robin</stateless-bean-load-algorithm>
    </stateless-clustering>
    </stateless-session-descriptor>
    <enable-call-by-reference>true</enable-call-by-reference>
    </weblogic-enterprise-bean>
    ........

    Hi,
    For a JEE5 EJB module, rather than using EJBGen, you can use WLS specific annotations for configuring common settings. If you follow the link below, you can see a list of supported EJB annotations. Disregard the fact that the documentation section title is WebLogic Kodo Annotations. That is incorrect and I've filed a bug for it.
    http://edocs.bea.com/wls/docs103/ejb30/annotations.html#wp1438036.
    Unfortunately, we don't yet support setting all weblogic-ejb-jar.xml configuration values via annoations so in some cases a weblogic-ejb-jar.xml is still required.
    You can hand edit your weblogic-ejb-jar.xml and the example you posted below should work fine.
    - Matt

  • How to parse xml and import to execel

    pls let me know how to parse XML file and import all data to execel sheet.

    Hi Mandya,
    This is outside of the normal use case for TestStand. It would be best to use a code module (developed in LabVIEW, C, or any other language) to accomlish this and then call it from a step in TestStand. You can find examples on ActiveX here:
    http://forums.ni.com/t5/NI-TestStand/Controlling-Excel-from-TestStand-with-Activex-Automation/td-p/1...
    I hope this helps.
    Frank L.
    Software Product Manager
    National Instruments

  • Java stored proc performance parsing XML docs

    Hi
    We are using ORACLE 8i(8.1.6). I have a JAVA Stored procedure that parses XML doc and returns tha values. If I am testing on the box, I get an avg. return time of 2 secs. If I have 20 users, my return time for all went to 25 to 35 secs?
    Are there any parameters on ORACLE I can modify to increase the performance. We are developing app for 1000 to 1500 users. I dont want to guess the time based on my test with 20 users.
    Any help will be greatly appreciated.
    Thank You
    Raju

    Raju,
    Oracle 8.1.7 should be better choice for you since it does have the XML stuff
    natively compiled.
    Regarding scaleability the JVM should scale
    very well. However let us know what you find.
    - Stefan

  • How to compare after parsing xml file

    Hi,
    following code, parse the input.xml file, counts how many nodes are there and writes the node name and its value on screen.
    1) i am having trouble writing only node name into another file instead of writing to screen.
    2) after parsing, i like to compare each node name with another .xsd file for existence.
    Please keep in mind that, input.xml is based on some other .xsd and after parsing i have comparing its tag with another .xsd
    Need you help guys.
    thanks
    * CompareTags.java
    import java.io.*;
    import org.w3c.dom.*;
    import org.xml.sax.*;
    import javax.xml.parsers.*;
    import javax.xml.transform.*;
    import javax.xml.transform.dom.*;
    import javax.xml.transform.stream.*;
    /** This class represents short example how to parse XML file,
    * get XML nodes values and its values.<br><br>
    * It implements method to save XML document to XML file too
    public class CompareTags {
    private final static String xmlFileName = "C:/input.xml";
         int totalelements = 0;
    /** Creates a new instance of ParseXMLFile */
    public CompareTags() {
    // parse XML file -> XML document will be build
    Document doc = parseFile(xmlFileName);
    // get root node of xml tree structure
    Node root = doc.getDocumentElement();
    // write node and its child nodes into System.out
    System.out.println("Statemend of XML document...");
    writeDocumentToOutput(root,0);
                   System.out.println("totalelements in xyz tag " + totalelements);
              System.out.println("... end of statement");
    /** Returns element value
    * @param elem element (it is XML tag)
    * @return Element value otherwise empty String
    public final static String getElementValue( Node elem ) {
    Node kid;
    if( elem != null){
    if (elem.hasChildNodes()){
    for( kid = elem.getFirstChild(); kid != null; kid = kid.getNextSibling() ){
    if( kid.getNodeType() == Node.TEXT_NODE ){
    return kid.getNodeValue();
    return "";
    private String getIndentSpaces(int indent) {
    StringBuffer buffer = new StringBuffer();
    for (int i = 0; i < indent; i++) {
    buffer.append(" ");
    return buffer.toString();
    /** Writes node and all child nodes into System.out
    * @param node XML node from from XML tree wrom which will output statement start
    * @param indent number of spaces used to indent output
    public void writeDocumentToOutput(Node node,int indent) {
    // get element name
    String nodeName = node.getNodeName();
    // get element value
    String nodeValue = getElementValue(node);
    // get attributes of element
    NamedNodeMap attributes = node.getAttributes();
    System.out.println(getIndentSpaces(indent) + "NodeName: " + nodeName + ", NodeValue: " + nodeValue);
    for (int i = 0; i < attributes.getLength(); i++) {
    Node attribute = attributes.item(i);
    System.out.println(getIndentSpaces(indent + 2) + "AttributeName: " + attribute.getNodeName() + ", attributeValue: " + attribute.getNodeValue());
    // write all child nodes recursively
    NodeList children = node.getChildNodes();
              //int totalelements = 0;
    for (int i = 0; i < children.getLength(); i++) {
    Node child = children.item(i);
                   //     System.out.println("child value.."+child);
    if (child.getNodeType() == Node.ELEMENT_NODE) {
    writeDocumentToOutput(child,indent + 2);
                             if(node.getNodeName() == "DATA"){
                             totalelements = totalelements+1;}
                        //System.out.println("totalelements in DATA tag " + totalelements);
    /** Parses XML file and returns XML document.
    * @param fileName XML file to parse
    * @return XML document or <B>null</B> if error occured
    public Document parseFile(String fileName) {
    System.out.println("Parsing XML file... " + fileName);
    DocumentBuilder docBuilder;
    Document doc = null;
    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    docBuilderFactory.setIgnoringElementContentWhitespace(true);
    try {
    docBuilder = docBuilderFactory.newDocumentBuilder();
    catch (ParserConfigurationException e) {
    System.out.println("Wrong parser configuration: " + e.getMessage());
    return null;
    File sourceFile = new File(fileName);
    try {
    doc = docBuilder.parse(sourceFile);
    catch (SAXException e) {
    System.out.println("Wrong XML file structure: " + e.getMessage());
    return null;
    catch (IOException e) {
    System.out.println("Could not read source file: " + e.getMessage());
    System.out.println("XML file parsed");
    return doc;
    /** Starts XML parsing example
    * @param args the command line arguments
    public static void main(String[] args) {
    new CompareTags();
    }

    hi,
    check out the following links
    Check this blog to extract from XML:
    /people/kamaljeet.kharbanda/blog/2005/09/16/xi-bi-integration
    http://help.sap.com/saphelp_nw04/helpdata/en/fe/65d03b3f34d172e10000000a11402f/frameset.htm
    Check thi link for Extract from any DB:
    http://help.sap.com/saphelp_nw04s/helpdata/en/58/54f9c1562d104c9465dabd816f3f24/content.htm
    regards
    harikrishna N

  • Splitting the XML Payload in BPEL

    Hi
    <Sales order>
    <order>
    <orderno>1200</orderno>
    <ordered details>testing</ordered details>
    </order>
    <order>
    <orderno>1201</orderno>
    <ordered details>testing2</ordered details>
    </order>
    </sales order>
    i need to split the XML payload and send the different request.
    Example 5 sales order details are there in the XML payload. i need to send 5 different request.
    Can you anyone guide me using BPEL.
    Thanks Rahul

    http://clemensblog.blogspot.com/2006/03/bpel-looping-over-arrays-collections.html
    http://oraclebpelindepth.blogspot.com/2008/09/arrays-in-bpel_21.html
    with the while loop you can loop over your orders in the array, and for every order do for example the invoke to your other service

  • How to parse xml file in midlet

    Hi Guys,
    i wish to parse xml file and display it in my midlet. i found api's supporting xml parsing in j2se ie., in java.net or j2se 5.0. Can u please help me what package to use in midlet?
    how to parse xml info and display in midlet? Plz reply soon......Thanks in advance....

    i have exactly the same problem with KXml2, but using a j2me-polish netbeans project.
    i've tried to work around with similar ways like you, but none of them worked. now i've spent 3 days for solving this problem, i'm a bit disappointed :( what is wrong with setting the downloaded kxml2 jar path in libraries&resources?
    screenshot

  • Parse XML files

    Hi
    Anyone know about support for parsing XML files in LabVIEW?
    (I mean specific XML support, I'm familiar with LabVIEWs file functions)
    regards
    Jan
    Sent via Deja.com http://www.deja.com/
    Before you buy.

    I assume you are referring to:
    http://www.savarese.org/oro/software/OROMatcher1.1.html
    Have you considered asking Savarese?
    Peace,
    Cameron Purdy
    Tangosol, Inc.
    http://www.tangosol.com
    +1.617.623.5782
    WebLogic Consulting Available
    "Laurent Mentek" <[email protected]> wrote in message
    news:[email protected]..
    Hi all,
    I'm started to develop with BEA WebLogic and I use ORACLE 8.1.6
    database.
    We need to map some XML tags as metadata in the database.
    Here is a concrete example with part of our XML files:
    XML files :
    <target>EDU</target>
    <question>
    <para>
    Please could you provide some references on nutritional status in
    the frail elderly?
    </para>
    </question>
    I use OROMatcher to parse xml files and it work fine.
    I can extract every element in line with success , but don't extract the
    value in <para> tag, for example.
    I don't no how to use the MULTILINE_MASK option and the ^ or $ to get
    this line.
    Anyone could give me an example of metadatas extaction using or no the
    MULTILINE_MASK option?
    Thanks a lot for your help.
    Laurent.

  • "Error while parsing SOAP XML payload: no element found" received when invoking Web Service

    Running PB 12.1 Build 7000.  Using Easysoap.  Error ""Error while parsing SOAP XML payload: no element found" received when invoking Web Service".  This error does not appear to be coming from the application code.  Noticed that there were some erroneous characters showing up within the header portion of the XML ("&Quot;").  Not sure where these are coming from.  When I do a find within the PB code for ""&quot;" it gets located within two objects, whereas they both reference a "temp_xml_letter".  Not sure where or what temp_xml_letter resides???   The developer of this is no longer with us and my exposure to WSDL and Web Services is rather limited.  Need to get this resolved...please.
    This is the result of the search.  Notice the extraneous characters ("&quot;"):
    dar1main.pbl(d_as400_mq_xml)
    darlettr.pbl(d_email_xml)
    ---------- Search: Searching Target darwin for 'temp_xml'    (9:52:41 AM)
    ---------- 2 Matches Found On "temp_xml":
    dar1main.pbl(d_as400_mq_xml).d_as400_mq_xml:  export.xml(usetemplate="temp_xml_letter" headgroups="1" includewhitespace="0" metadatatype=0 savemetadata=0  template=(comment="" encoding="UTF-8" name="temp_xml_letter" xml="<?xml version=~"1.0~" encoding=~"UTF-16LE~" standalone=~"yes~"?><EmailServiceTransaction xmlns=~"http://xml.xxnamespace.com/Utility/Email/EmailService" ~" xmlns:imc=~"http://xml.xxnamespace.com/IMC~" xmlns:xsi=~"http://www.w3.org/2001/XMLSchema-instance~" xmlns:root=~"http://xml.xxnamespace.com/RootTypes~" xmlns:email=~"http://xml.xxnamespace.com/Utility/Email~" xsi:schemaLocation=~"http://xml.xxnamespace.com/Utility/Email/EmailService http://dev.xxnamespace.com/Utility/Email/EmailService/V10-TRX-EmailService.xsd~"><EmailServiceInformation><EmailServiceDetail __pbband=~"detail~"><ApplicationIdentifier> applicationidentifier </ApplicationIdentifier><AddresseeInformation><AddresseeDetail><Number> number </Number></AddresseeDetail></AddresseeInformation><EmailMessageInformation><Ema
    darlettr.pbl(d_email_xml).d_email_xml:  export.xml(usetemplate="temp_xml_letter" headgroups="1" includewhitespace="0" metadatatype=0 savemetadata=0  template=(comment="" encoding="UTF-8" name="temp_xml_letter" xml="<?xml version=~"1.0~" encoding=~"UTF-16LE~" standalone=~"yes~"?><EmailServiceTransaction xmlns=~"http://xml.xxnamespace.com/Utility/Email/EmailService" ~" xmlns:imc=~"http://xml.xxnamespace.com/IMC~" xmlns:xsi=~"http://www.w3.org/2001/XMLSchema-instance~" xmlns:root=~"http://xml.xxnamespace.com/RootTypes~" xmlns:email=~"http://xml.xxnamespace.com/Utility/Email~" xsi:schemaLocation=~"http://xml.xxnamespace.com/Utility/Email/EmailService http://dev.xxnamespace.com/Utility/Email/EmailService/V10-TRX-EmailService.xsd~"><EmailServiceInformation><EmailServiceDetail __pbband=~"detail~"><ApplicationIdentifier> applicationidentifier </ApplicationIdentifier><AddresseeInformation><AddresseeDetail><Number> imcnumber </Number></AddresseeDetail></AddresseeInformation><EmailMessageInformation><Ema
    ---------- Done 2 Matches Found On "temp_xml":
    ---------- Finished Searching Target darwin for 'temp_xml'    (9:52:41 AM)

    Maybe "extraneous" is an incorrect term.  Apparantly, based upon the writeup within Wiki, the parser I am using does not interpret the "&quot;"?  How do I find which parser is being utilized and how to control it?
    <<<
    If the document is read by an XML parser that does not or cannot read external entities, then only the five built-in XML character entities (see above) can safely be used, although other entities may be used if they are declared in the internal DTD subset.
    If the document is read by an XML parser that does read external entities, then the five built-in XML character entities can safely be used. The other 248 HTML character entities can be used as long as the XHTML DTD is accessible to the parser at the time the document is read. Other entities may also be used if they are declared in the internal DTD subset.
    >>>

  • How to store ,retreive and edit  data from an xml file

    I am new to XML. I am creating a phone book in JSP with backend as an XML file.How can I store retrieve and edit datas from a jsp file.
    Please provide me with examples.I dont want to use bean.
    Please provide examples

    You will have to do some leg-work yourself. You will probably want to use DOM to parse and manipulate your XML data. Xerces (xml.apache.org) is a good open source parser. There are extensive examples on their site.
    - Saish

Maybe you are looking for

  • System Start up issue in my ABAP + JAVA system

    HI, when i try to start up my SAP (ABAP+JAVA) system, server processes fail to start. Below is the trace file. Though it says missing file jvmx.jar, not sure if this is the reason for the start up issue. Thanks to check and assist. trc file: "D:\usr\

  • Can't sign Acrobat Pro 6 PDF with Reader 8

    I have many documents created with Acrobat Pro 6. Some have signature fields (forms). My manager has Reader 8. When she opens the documents, the "sign" capability is not available. She clicks in the signature fields and nothing happens. From the File

  • PSE10 - Keyword tags not all showing when tagging faces?

    When I import a new picture, if I manually add a face tagging box, then click on the text box and type the first letter of a name, only certain of my keyword tag names show up? Some do not??? For instance, if I have the names Bella, Bill and Bess alr

  • Facing a problem in writing textfile, badly need help.

    I am already close to finishing this. Just that the problem i'm facing is that i can't seem to log the data into the textfile. It says that the concatenate has an error or something. That's the problem because i can't seem to find it. Do i have to us

  • Oracle lite 10.2.0.2.0?

    I saw a patch wich has to be installed on top of 10.2.0.2.0 on metalink. Does that mean this version is released? I can't find it anywhere, but it should have fixed something we encountered. thanks in advance, Arjaan