Converting ResultSet to XML by OracleXMLQuery

Hello,
I'm newbie in XML and I have following problem:
I'm using OracleXMLQuery to convert ResultSet from oracle db to XML document. I'm using getXMLDOM()(from oracle package) to convert this OracleXMLQuery into DOM representation. I can extract node names but all values of the nodes are null's (if I convert the document to string and put it on the screen, the values are connect). Here's my code:
QracleXMLQuery qry;
ResultSet rset = (ResultSet)stmt.getObject(1);
qry = new OracleXMLQuery(conn,rset);
      qry.setRaiseNoRowsException(true);
      qry.setRaiseException(true);
      qry.keepObjectOpen(true);
      qry.useNullAttributeIndicator(true);
Document d=(Document)qry.getXMLDOM();
        //---to this point all seems to be correct
        // -OracleXMLQuery object stores correct xml document and
        // qry.getXMLDOM() return good Document object
  NodeList nl=d.getElementsByTagName("some_tag_name");
  for(int i=0;i<nl.getLength();i++){
       Node temp=nl.item(i);
       System.out.println(temp.getNodeValue()); //null's
       System.out.println(temp.getNodeName()); //correct name of the string
       }Maybe i'm missing something, as I wrote earlier I'm newbie in XML - I would be very grateful for any help. Thanks in advance!

Thanks for your reply - it really helped. I have another problem,maybe some of you may help me: I have two DOM documents and I want to join then like this
Documant a:
<?xml version = '1.0'?>
<ROWSET>
     <ROW num="1">
        <attr1>sometext1</attr1>
        <attr2>sometext2</attr2>
        <attr3>sometext3</attr3>
     </ROW>
     <ROW num="2">    
     </ROW>
     <ROW num="3">
     </ROW>
</ROWSET>Doc b
<?xml version = '1.0'?>
<attrib>
  <ROW num="1">
     <atr1>sometext1</atr1>
     <text>othertext1</text>
  </ROW>  
  <ROW num="2">
     <atr2>sometext2</atr2>
     <text>othertext1</text>
  </ROW>
  <ROW num="3">
     <atr3>sometext3</atr3>
     <text>othertext1</text>
   </ROW>
</attrib>Now I want to insert the whole <attrib>...</attrib> section from document b as a node to document a in for example <ROW num="1">...</ROW> section. I've tried to create Node element form document b (<attrib></attrib>) and use insertBefore() method on Node <ROW num="1"></ROW> but I have a nullpointer exception - well it probably wasn't good idea.I hope my description is clear, I vould be happy for any advice. Thanks in advance

Similar Messages

  • Convert ResultSet - Xml with Xml Schema in java

    Hi
    I am using Web Services created in java and will be used from .Net client. Since its a cross platform, so I need to convert the Java ResultSet to XML stream (with schema) so that it could be accesed by .NET client. So I want to know how to convet a Java ResultSet into the desired xml stream (with schema).I know .NET provides this facility through some methods of DATASET.
    Will anybody tell me of any utility, tools or the methods so that I can accomplish this task.
    Thank in advance
    nitin

    I would think that the easiest way to do this would be to use web-services. Get the JWSDP. I don't think there is a direct way to go from ResultSet to XML. You'd have to write or find an external tool, though Oracle can create XML straight from the database.

  • How to convert ResultSet of MySQL to XML

    How can we convert ResultSet of MySQL using Hibernate into XML packet for JSP?

    maybe something like this
    http://beansource.sourceforge.net

  • Converting string to XML

    Dear All,
    I am using PI 7.1
    I am trying to invoke a third party SOAP API which accepts request in the form of a string which has embedded xml and also return a string which has xml embedded in it.
    To send the xml as string, I used the feature "Retun as XML" in mapping and it worked fine.
    But the response which has xml embedded, needs to be converted back to XML message.
    I understand that we can write parsers in java, ABAP and also do XSLT mapping.
    Just wanted to know that is there any "out of the box" feature to do the same.
    Please refrain from providing links to java mappings or xslt as I have gone through them already.
    regards,
    Piyush

    Hi Piyush,
                      All parsers will fail to parse the XML message you are getting. Since you are getting the following tag twice within the XMl
    "<?xml version="1.0"?>"
    This tag can be present in an document only once in begining of the document. First you need to remove this tag from appearing in source.
    Suppose you are able to do that then your XML structure will become something like this
    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    <ns1:AuthenticateResponse xmlns:ns1="urn:Login" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">
    <return xsi:type="xsd:string"><MessageResponse sessionid=";jsessionid=FxZLTxtJnXJttpW6gMhJ06kyn00tfSgjt9ZwbzJ55CXGn92S8L6f!-444760742!1311845684753" status="SUCCESS" topicprefix="ND-DSK-117.CXL_HMEL_DB"><Entity name="REF_PERSON"><Property name="last_access_dt" value="20110728145937" type="DATE"/><Property name="modify_person_num" value="21" type="INTEGER"/><Property name="persontopic" value="350523952" type="STRING"/><Property name="login_result_ind" value="0" type="INTEGER"/><Property name="login_result_reason" value="" type="STRING"/><Property name="bypass_drafts" value="0" type="STRING"/><Property name="stl_check_swap_option_pricing_end" value="1" type="BOOLEAN"/><Property name="stl_update_provisional_cashflows" value="0" type="BOOLEAN"/><Property name="stl_autoinvoice_costs" value="1" type="BOOLEAN"/><Property name="stl_allow_payments_from_agents" value="0" type="BOOLEAN"/><Property name="stl_payment_allocation_at_invoice_detail_level" value="1" type="BOOLEAN"/><Property name="last_db_reloaded_on" value="" type="DATE"/><Property name="xl_mode_ind" value="0" type="INTEGER"/><Property name="Xchange_enabled" value="1" type="INTEGER"/><Property name="Xchange_server" value="XCHANGE" type="STRING"/><Property name="ipaddress" value="10.60.4.80" type="STRING"/><Property name="appname" value="CommodityXL" type="STRING"/><Property name="version" value="7.XL7.08.17E" type="STRING"/><Property name="econfirm.server.enabled" value="0" type="BOOLEAN"/></Entity></MessageResponse></return>
    </ns1:AuthenticateResponse>
    Then you can use the following java mapping code to remove the SOAP envelop.
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.util.Map;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import com.sap.aii.mapping.api.StreamTransformation;
    import com.sap.aii.mapping.api.StreamTransformationException;
    public class RemoveSoapEnvelopSDN implements StreamTransformation{
    public void execute(InputStream in, OutputStream out)
    throws StreamTransformationException {
    try
         DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
         DocumentBuilder builderel=factory.newDocumentBuilder();
         /*input document in form of XML*/
         Document docIn=builderel.parse(in);
         /*document after parsing*/
         Document docOut=builderel.newDocument();
         TransformerFactory tf=TransformerFactory.newInstance();
         Transformer transform=tf.newTransformer();
         Element root;
         Node p;
         NodeList l;
         int mm,n1;
         //if you need to include namespace use next two lines
         //root=docOut.createElement("ns0:MessageResponse");
         //root.setAttribute("xmlns:ns0","http://connectsystems.be/MAINFR/AccDocument");
         root=docOut.createElement("MessageResponse");
         p=docIn.getElementsByTagName("MessageResponse").item(0);
         l=p.getChildNodes();
         n1=l.getLength();
         for(mm=0;mm<n1;++mm)
              Node temp=docOut.importNode(l.item(mm),true);
              root.appendChild(temp);
         docOut.appendChild(root);
         transform.transform(new DOMSource(docOut), new StreamResult(out));
    catch(Exception e)
         e.printStackTrace();
    public void setParameter(Map arg0) {
    public static void main(String[] args) {
    try{
         RemoveSoapEnvelopSDN genFormat=new RemoveSoapEnvelopSDN();
         FileInputStream in=new FileInputStream("C:\\Apps\\my folder\\sdn\\sdn6.xml");
         FileOutputStream out=new FileOutputStream("C:\\Apps\\my folder\\sdn\\removedEnvelopSdn6.xml");
         genFormat.execute(in,out);
    catch(Exception e)
    e.printStackTrace();
    You can add attributes to the tags as per your requirement. I have commnented those lines in the java code.
    The output will look like this
    http://postimage.org/image/2b2czww90/
    Hope this helps.
    Regards
    Anupam

  • Converting String To XML Format and send as attachment

    Hi
    My requirement is to convert String into XML Format and that XML File i have to send as an attachment
    can any one one give solution for this Problem.
    Thank you
    Venkatesh.K

    hi,
    i m filling the itab first and converting to xml
    itab contaning these data
    GS_PERSON-CUST_ID   = '3'.
    GS_PERSON-FIRSTNAME = 'Bill'.
    GS_PERSON-LASTNAME  = 'Gates'.
    APPEND GS_PERSON TO GT_PERSON.
    GS_PERSON-CUST_ID   = '4'.
    GS_PERSON-FIRSTNAME = 'Frodo'.
    GS_PERSON-LASTNAME  = 'Baggins'.
    APPEND GS_PERSON TO GT_PERSON.
    after conversion data is coming like that
    #<?xml version="1.0" encoding="utf-16"?>
    <CUSTOMERS>
      <item>
        <customer_id>0003</customer_id>
        <first_name>Bill</first_name>
        <last_name>Gates</last_name>
      </item>
      <item>
        <customer_id>0004</customer_id>
        <first_name>Frodo</first_name>
        <last_name>Baggins</last_name>
      </item>
    </CUSTOMERS>
    but errors are  1) # is coming at the first
                            2)for 'encoding="utf-16"?>', it is not coming perfectly, some other data (iso-8859-1) should come here
    can anybody plz solve it.
    regards,
    viki

  • Converting string to XML format

    Hi All,
    I have a requirement to convert string to xml format and download it. Atpresent, I have a string which is a collection of xml tags. I want to convert this string to xml format like <VALUE004>20387899.437</VALUE004>
    <VALUE005>20387899.437</VALUE005>
    <VALUE006>20387899.437</VALUE006>
    Is there any function module for this.

    Chk this thread.
    Re: Regd: File Conversion to XML format

  • Converting string to xml in xslt

    Hi we are trying to convert string to xml in xslt but it is getting errored out.
    We have followed the procedure mentioned at http://download.oracle.com/docs/cd/A91202_01/901_doc/appdev.901/a88894/adx04xsl.htm under the section "How Do I Convert A String to a Nodeset in XSL?".
    Standard procedure mentioned by oracle is not working. Is it a known bug?

    Chk this thread.
    Re: Regd: File Conversion to XML format

  • Methods in bapi used to convert data into XML

    Methods in bapi used to convert data into XML,
    how to implement those also,
    points will be rewarded
    Thank you,
    Regards,
    Jagrut BharatKumar Shukla

    Hi
    Check this
    http://www.sap-img.com/abap/sample-xml-source-code-for-sap.htm
    https://forums.sdn.sap.com/click.jspa?searchID=2889167&messageID=3406594
    Reward points for useful Answers
    Regards
    Anji

  • Convert Excel to XML file

    Hi Guys,
    I need to generate the XML from Excel file. The XML file will have the definition like this:
    <people_list>
    <name>Fred Bloggs</name>
    <birthdate>27/11/2008</birthdate>
    <gender>Male</gender>
    </people_list>
    The Excel file will look like this:
    A B C
    1 Fred Bloggs 10/21/2008 Male
    2 ABC 12/23/2008 Female
    3 XYZ 07/16/2008 Male
    All the values in name,birthdaye,gender will come from the Excel file. I am having 100 rows in the Excel file with the data and I want to parse this excel file and create the XML file with the above template.
    Any ideas how to do this?
    Thanks,
    Mahesh

    Hi Mahesh,
    there are tons of ways to do what you need. It all depends on how your workflow is organized and how complicated it may become.
    Alternative 1:
    Export your Excel file as a cvs and convert cvs to XML (which shouldn't be so hard).
    Pro: Relative easy transformation.
    Con: Every time you want to convert the Excel file to XML you first needs to export it out of Excel by a manual step.
    Alternative 2:
    Save you Excel file as XML (e. g. the new *.xslx documents) and transform it as you like.
    Pro: Very clean way to do this. You can access the single source Excel file directly from Java. No further steps needed.
    Con: It's very very hard to program because the Excel xml structure is ridiculously complex.
    Alternative 3:
    You can create a little Excel VBA Script which generates the XML File.
    Pro: Easy programing.
    Con: Needs some experience in Visual Basic 6 programming.
    Alternative 4:
    Use http://jexcelapi.sourceforge.net/ or any other Excel-API to Access the Excel application out of Java.
    Pro: Clean way to do it. You need no further manual actions to prepare something. (maybe the most flexible and at the same time easyest way)
    Con: Additional license.
    Best Wishes
    esprimo

  • Convert FMB to XML File on Unix

    Hello,
    I want to convert a FMB-File to XML in my HP-UX-Middletier-Environment.The Script frm2xml.sh is only shipped with IDS.
    Can someone upload the frmf2xml.sh from a linux or Solaris IDS-Enviroment?
    Robert

    So if we were to keep text-based source files, the process would have to be:
    - check-out to local working copy
      - convert XML to FMB
        - make changes using Forms Developer
      - convert FMB to XML
    - commit to svn
    I'm concerned about the side-effects of the conversion process (edge-cases, incompatibilities), and I also expect that even with some automation, the above will be a pretty slow process that will slow the team down. I guess we'll probably stick with fmb.
    I guess as a compromise, it may be worthwhile generating the xml or fmt alongside the fmb and committing both. At least we'd then have a text-based file to compare revisions with. So the process then becomes:
    - check-out to local working copy
      - make changes using Forms Developer
      - generate XML from FMB
    - commit both to svn
    I'm still baffled as to why Oracle has chosen a binary source format, even 15 years ago. This basically precludes a vast number of tools and techniques that are essential to the software craft :(

  • Step by step bapi to convert SAP to XML please its urgent

    step by step bapi to convert SAP to XML please its urgent
    full points if with full example and coding in ABAP,
    Thank you,
    Regards,
    Jagrut Shukla

    yes i want to convert Catsdb table into xml format and safely in server, i.e secured  place

  • Convert XMLList to XML in AS3?

    Hello,
    I am trying to figure out how to convert an XMLList that I
    retreived from an XML instance back into well-formed XML in Flash
    CS3. Here is what I am doing.
    - I have an XML document loaded and I am displaying the
    contents in a datagrid component (which is working well).
    - I am then filtering the XML to obtain a subset of data by
    first obtaining an XMLList representing all elements of my XML
    instance and then filtering the list on a particular element (this
    is working well).
    - Now I want to display my filtered results in the datagrid
    and here lies the problem because the datagrid can't use an XMLList
    as a dataprovider. How do I convert this XMLList back into well
    formed XML so I can use it as my grid's dataprovider? I need to
    somehow get a root tag back on.
    Could I somehow use toXMLString() and then convert that to
    XML?
    Thank you in advance for any advice.
    TH

    I solved this so I thought I would post how I did it in case
    anyone would find this useful.
    1. First, convert your XMLList to an xml string:
    var yourXMLString:String = yourXMLList.toXMLString();
    2. Next, add a root tag to the beginning and end of your xml
    string.
    yourXMLString=
    "<your_root_tag>"+yourXMLString+"</your_root_tag>";
    3. Convert the string to xml.
    var yourNewXML:XML=new XML(yourXMLString);
    yourNewXML is now well-formed xml and will work as a
    dataprovider.
    TH

  • Converting IDOC to XML

    Hi,
    I have an application where i have to convert an IDOC to XML format so that it can be handled by webmethods.
    I want to know how to convert IDOC to XML. I have seen that in SAP there are two port types, XML and XML HTTP. Are they used for posting an IDOC in XML format at defined port.
    When i tried to generated a test IDOC with port type as XML, it has created an xxx.XML file in application server but i an unable to display it.
    1). Can any one pls. tell me how to convert IDOC to
    XML??? What are the different methods ( if available)
    2). DO i need to have any extra component for this??
    3). what are XML and XML http ports are for.
    Pls. help me as this is very urgent.
    Thanks in advance.
    Pratik

    Hi,
    Does xxx.XML contain no data? Or you are just not able to display it (try opening it in notepad).
    1 - You are doing it right. Using XML port should be enough.
    2 - You don't need anything additional.
    3 - XML port gives you an option like a file port (you get the idoc in an XML file) for batch type interface. XML http will let you post the XML data realtime to an web server that accepts XML messages.
    If your partner system can take http messages, you can use http port to send the IDOC directly to that system, else you can create the XML file and send it in batch mode.
    hope this helps,
    cheers,
    Ajay

  • Converting audio to xml form

    hi
    i need to know how to convert audio to xml form.. can any one help me on this...

    take a look at this article:
    http://www.javaworld.com/javaworld/javatips/jw-javatip117.html?tip

  • [Q] convert DOM to XML Document

    Hi,
    Is there any class or library which convert DOM to XML document?
    ----- java program ------------
    import org.w3c.dom.*;
    import org.apache.crimson.tree.XmlDocument;
    public class Sample {
      public static void main(String args[]) {
        // create a document and root element
        Document doc = new XmlDocument();
        Element root = doc.createElement("html");
        doc.appendChild(root);
        // append a data
        Element body = doc.createElement("body");
        root.appendChild(body);
        body.appendChild(doc.createTextNode("Hello"));
        // convert DOM to XML Document
    }----- expected result ----------
    <html>
    <body>
      Hello
    </body>
    </html>Could you help me?

    Hi,
    Look at the package javax.xml.transform
    or
    try the following code:
    I tried the following code.
    ----- java program ------------
    import javax.xml.parsers.*;
    import org.w3c.dom.*;
    import javax.xml.transform.*;
    import javax.xml.transform.dom.*;
    import javax.xml.transform.stream.*;
    import java.io.OutputStream;
    public class Sample {
      public static void main(String[] args) {
        try {
          // create a document and root element
          Document doc = DocumentBuilderFactory.newInstance()
                                .newDocumentBuilder()
                                .newDocument();
          Element root = doc.createElement("html");
          doc.appendChild(root);
          // append a data
          Element body = doc.createElement("body");
          root.appendChild(body);
          body.appendChild(doc.createTextNode("Hello"));
          Element ul = doc.createElement("ul");
          String[] list = {"foo", "bar", "baz"};
          for (int i=0; i<list.length; i++) {
           Element li = doc.createElement("li");
           li.appendChild(doc.createTextNode(list));
         ul.appendChild(li);
    body.appendChild(ul);
    // convert DOM to XML Document
    TransformerFactory factory = TransformerFactory.newInstance();
    Transformer transformer = factory.newTransformer();
    //OutputStream stream = new FileOutputStream("output.xml");
    OutputStream stream = System.out;
    transformer.transform(new DOMSource(doc), new StreamResult(stream));
    } catch (Exception ex) {
         ex.printStackTrace();
    ----- result ------------
    <html>
    <body>Hello<ul>
    <li>foo</li>
    <li>bar</li>
    <li>baz</li>
    </ul>
    </body>
    </html>Great! Very thanks!

Maybe you are looking for

  • How to re-download imovie after deleting it?

    I downloaded the free imovie app when I bought my new 5S along with garageband and iphoto etc. I ended up deleting a bunch of the free apps not thinking that I would use them. Now when i go onto purchased apps in the app store and try and install imo

  • How can I get the length of a sequence using script

    I am trying to get the length of an image sequence that was imported using importOptions.sequence.  I need to check that the length is a correct number, and if it is too short/long it gives an error message. Is there a way to do this? Thanks

  • ZEN Microphoto: firmware, WMP11, "MTP device not recognized" probl

    Hi fellow Creative haters,?My story is much like many I have read on the forum. I purchased a ZEN 8GB Microphoto in Nov 2006, its hard dri've?died in Jan 2007 and after much suffering from Creative Support, had the unit replaced, then 2 days ago the

  • No more output streams available error

    I have created a class to connect to a webserver extending the Thread class now using that i am trying to send data to the server with a timere task every 5 seconds first time works fine but when it tries to send for the second time it gives me an er

  • Update Termiante Problem in the VF02

    Dear SAP Technical Guru's, I am facing Update termiante problem in the VF02 Screen . MESSAGE Update was terminated *System ID.... MRD Client....... 100 User..... PWC Transaction.. VF01 Update key... BE944DDDC5AEF1338261001635B0CD06 Generated.... 09.0