Problems to read out an XML

Hello together
I have a problem to read out an XML file with JDOM. I am in charge to read out one attribute of the XML with JDOM. But my XML file has more than one Attribute of the same type. It is repeated more than once... It looks like that...
<Resolution v="PT15M"/>
               <Interval>
                    <Pos v="1"/>
                    <Qty v="0"/>
               </Interval>
               <Interval>
                    <Pos v="2"/>
                    <Qty v="0"/>
               </Interval>
               <Interval>
                    <Pos v="3"/>
                    <Qty v="0.379"/>
               </Interval>
               <Interval>
                    <Pos v="4"/>
                    <Qty v="2.453"/>
               </Interval>
               <Interval>
                    <Pos v="5"/>
                    <Qty v="0"/>
               </Interval>
               <Interval>
                    <Pos v="6"/>
                    <Qty v="0"/>
               </Interval>
               <Interval>
                    <Pos v="7"/>
                    <Qty v="1.108"/>
               </Interval>
               <Interval>
                    <Pos v="8"/>
                    <Qty v="2.22"/>
               </Interval>
               <Interval>
                    <Pos v="9"/>
                    <Qty v="0"/>
               </Interval>
               <Interval>
                    <Pos v="10"/>
                    <Qty v="0.247"/>
               </Interval>
               <Interval>
                    <Pos v="11"/>
                    <Qty v="0.712"/>
               </Interval>
               <Interval>
                    <Pos v="12"/>
                    <Qty v="0.964"/>
               </Interval>
Now, I want to read out the Qty from 1 to 6 and I tried it now with an Iterator but it doesn't work...I don't know what the problem is, so please help me...
I also post the Java File here. I am sorry for y English..
package FahrplanXML;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import org.jdom.Attribute;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
public class Saxwer {
     //Variablendeklaration
     private File inFile;
     //Konstruktor
     public Saxwer(File in) {
          this.inFile = in;     
     //Weitergabe der Variablen durch return vorbereiten
     //public String getDtdVersion() {
          //System.out.println (scheduleDtdVersion);
          //return scheduleDtdVersion;     
     public void saxwer() throws JDOMException, IOException {
          //FileAuswahl filename = new FileAuswahl();
               System.out.println(inFile);
               SAXBuilder builder = new SAXBuilder();
               Document doc = builder.build(inFile);
               /*Elemente holen*/
               //1.Stufe
               //Root Element auslesen
               Element schedulemessage = doc.getRootElement();
               //2. Stufe
               //Childs von Root Element auslesen
               Element messageidentification = schedulemessage.getChild("MessageIdentification");
               Element messageversion = schedulemessage.getChild("MessageVersion");
               Element messagetype = schedulemessage.getChild("MessageType");
               Element processtype = schedulemessage.getChild("ProcessType");
               Element scheduleclassificationtype = schedulemessage.getChild("ScheduleClassificationType");
               Element senderidentification = schedulemessage.getChild("SenderIdentification");
               Element senderrole = schedulemessage.getChild("SenderRole");
               Element receiveridentification = schedulemessage.getChild("ReceiverIdentification");
               Element receiverrole = schedulemessage.getChild("ReceiverRole");
               Element messagedatetime = schedulemessage.getChild("MessageDateTime");
               Element scheduletimeinterval  = schedulemessage.getChild("ScheduleTimeInterval");
               Element scheduletimeseries  = schedulemessage.getChild("ScheduleTimeSeries");
               //3. Stufe
               // Childs von scheduletimeseries auslesen
               Element senderstimeseriesidentification = scheduletimeseries.getChild("SendersTimeSeriesIdentification");
               Element senderstimeseriesversion = scheduletimeseries.getChild("SendersTimeSeriesVersion");
               Element businesstype = scheduletimeseries.getChild("BusinessType");
               Element product = scheduletimeseries.getChild("Product");
               Element objectaggregation = scheduletimeseries.getChild("ObjectAggregation");
               Element outarea = scheduletimeseries.getChild("OutArea");
               Element outparty = scheduletimeseries.getChild("OutParty");
               Element measurementunit = scheduletimeseries.getChild("MeasurementUnit");
               Element period = scheduletimeseries.getChild("Period");
               //4. Stufe
               // Childs von period auslesen
               Element timeinterval = period.getChild("TimeInterval");
               Element resolution = period.getChild("Resolution");
               Element interval = period.getChild("Interval");
               //5. Stufe
               // Childs von interval auslesen
               Element position = interval.getChild("Pos");
               Element quantity = interval.getChild("Qty");
               /*Attribute holen*/
               //Attribute von Root Element (Stufe 1) auslesen (aus XML)
               String scheduleDtdVersion = schedulemessage.getAttributeValue ("DtdVersion"); 
               String scheduleDtdRelease = schedulemessage.getAttributeValue ("DtdRelease");
               //Attribute aus Stufe 2 auslesen (aus XML)
               String messageidentificationv = messageidentification.getAttributeValue ("v");
               String messageversionv = messageversion.getAttributeValue ("v");
               String messagetypev = messagetype.getAttributeValue ("v");
               String processtypev = processtype.getAttributeValue ("v");
               String scheduleclassificationtypev = scheduleclassificationtype.getAttributeValue ("v");
               String senderidentificationv = senderidentification.getAttributeValue ("v");
               String senderidentificationcodingscheme = senderidentification.getAttributeValue ("codingScheme");
               String senderrolev = senderrole.getAttributeValue ("v");
               String receiveridentificationv = receiveridentification.getAttributeValue ("v");
               String receiveridentificationcodingscheme = receiveridentification.getAttributeValue ("codingScheme");
               String receiverrolev = receiverrole.getAttributeValue ("v");
               String messagedatetimev = messagedatetime.getAttributeValue ("v");
               String scheduletimeintervalv = scheduletimeinterval.getAttributeValue ("v");
               //Attribute aus Stufe 3 auslesen (aus XML)
               String senderstimeseriesidentificationv = senderstimeseriesidentification.getAttributeValue ("v");
               String senderstimeseriesversionv = senderstimeseriesversion.getAttributeValue ("v");
               String businesstypev = businesstype.getAttributeValue ("v");
               String productv = product.getAttributeValue ("v");
               String objectaggregationv = objectaggregation.getAttributeValue ("v");
               String outareav = outarea.getAttributeValue ("v");
               String outareacodingscheme = outarea.getAttributeValue ("v");
               String outpartyv = outparty.getAttributeValue ("v");
               String outpartycodingscheme = outparty.getAttributeValue ("v");
               String measurementunitv = measurementunit.getAttributeValue ("v");
               //Attribute aus Stufe 4 auslesen (aus XML)
               String timeintervalv = timeinterval.getAttributeValue ("v");
               String resolutionv = resolution.getAttributeValue ("v");
               //Attribute aus Stufe 5 auslesen (aus XML)
               Iterator i = period.getChildren("Interval").iterator();
               while(i.hasNext()) {
                 Element currentElement = (Element)i.next();
                 Iterator j = currentElement.getAttributes().iterator();
                 System.out.print(j);
                 while(j.hasNext()) {
                      Attribute currentAttribute = (Attribute)j.next();
                   System.out.println("Attribute\t Name: "+currentAttribute.getName()+", Value: "+currentAttribute.getValue());
               String positionv = position.getAttributeValue ("v");
               String quantityv = quantity.getAttributeValue ("v");
               Detailoberflaeche xmluebergabe = new Detailoberflaeche(scheduleDtdVersion, scheduleDtdRelease, messageidentificationv, messageversionv, messagetypev, processtypev, scheduleclassificationtypev, senderidentificationv, senderidentificationcodingscheme, senderrolev, receiveridentificationv, receiveridentificationcodingscheme, receiverrolev, messagedatetimev, scheduletimeintervalv, senderstimeseriesidentificationv, senderstimeseriesversionv, businesstypev, productv, objectaggregationv, outareav, outareacodingscheme, outpartyv, outpartycodingscheme, measurementunitv, timeintervalv, resolutionv, positionv, quantityv);
               xmluebergabe.grundoberflaechen();
}Thank you for your help....
Kind regards
Roger

Hello together
I have a problem to read out an XML file with JDOM. I am in charge to read out one attribute of the XML with JDOM. But my XML file has more than one Attribute of the same type. It is repeated more than once... It looks like that...
<Resolution v="PT15M"/>
<Interval>
<Pos v="1"/>
<Qty v="0"/>
</Interval>
<Interval>
<Pos v="2"/>
<Qty v="0"/>
</Interval>
<Interval>
<Pos v="3"/>
<Qty v="0.379"/>
</Interval>
<Interval>
<Pos v="4"/>
<Qty v="2.453"/>
</Interval>
<Interval>
<Pos v="5"/>
<Qty v="0"/>
</Interval>
<Interval>
<Pos v="6"/>
<Qty v="0"/>
</Interval>
<Interval>
<Pos v="7"/>
<Qty v="1.108"/>
</Interval>
<Interval>
<Pos v="8"/>
<Qty v="2.22"/>
</Interval>
<Interval>
<Pos v="9"/>
<Qty v="0"/>
</Interval>
<Interval>
<Pos v="10"/>
<Qty v="0.247"/>
</Interval>
<Interval>
<Pos v="11"/>
<Qty v="0.712"/>
</Interval>
<Interval>
<Pos v="12"/>
<Qty v="0.964"/>
</Interval>
Now, I want to read out the Qty from 1 to 6 and I tried it now with an Iterator but it doesn't work...I don't know what the problem is, so please help me...
The problem is, that the Iterator doesn't bring out my Quantity Attribute (see part of the xml above). I didn't get any error messages, so I really don't know what the problem is. I am a beginner, so maybe you can help me...
I also post the Java File here. I am sorry for my English..
               /*Elemente holen*/
               //4. Stufe
               // Childs von period auslesen
               Element timeinterval = period.getChild("TimeInterval");
               Element resolution = period.getChild("Resolution");
               Element interval = period.getChild("Interval");
               //5. Stufe
               // Childs von interval auslesen
               Element position = interval.getChild("Pos");
               Element quantity = interval.getChild("Qty");
               /*Attribute holen*/
               //Attribute aus Stufe 4 auslesen (aus XML)
               String timeintervalv = timeinterval.getAttributeValue ("v");
               String resolutionv = resolution.getAttributeValue ("v");
               //Attribute aus Stufe 5 auslesen (aus XML)
               Iterator i = period.getChildren("Interval").iterator();
               while(i.hasNext()) {
               Element currentElement = (Element)i.next();
               Iterator j = currentElement.getAttributes().iterator();
               System.out.print(j);
               while(j.hasNext()) {
                    Attribute currentAttribute = (Attribute)j.next();
               System.out.println("Attribute\t Name: "+currentAttribute.getName()+", Value: "+currentAttribute.getValue());
               String positionv = position.getAttributeValue ("v");
               String quantityv = quantity.getAttributeValue ("v");
Thank you for your help....
Kind regards
Roger
Message was edited by:
superb
Message was edited by:
superb

Similar Messages

  • Read Out Loud States Authoring for Highlights

    Hello fellow Adobe fans,
    I usually Highlight my user manuals so it's easier to find things later.
    Today I turned on "Read out Loud" and for each Highlighted word it says:
    "Highlight Comment Christine July 31, 2012 7 hours 35 minutes and 1 sec (end link)"
    The "end link" is in parentheses because I'm not positive that's what it's saying.
    This is really annoying!   I've gone through the Preferences numerous times and the help files as well.  Is there a way to disable this?
    Does anyone know why it's doing this and how to stop it?  Or is my excessive use of Highlights the problem; perhaps "Read Out Loud" wasn't designed for it?  Although, even if it was just a few words; it's still extremely distracting.  I could see it's use if I was collaborating with a group; but surely there must be a way to turn this off for the average user?
    About the file: I saved a Microsoft web page by "printing" it to a file using my Quicken PDF Printer.  I'm using Adobe Reader v10.1.3 and Windows XP SP3.
    Thanks very much for your time 

    Great question!!! When I travel I would like to be able to listen to some multi page documents....it would be like a book on tape.

  • Read out properties generated by XLF files

    Dear community,
    I have a problem reading out property files generated by Web Dynpros XLS (S2X-Editor). What I have to do is generate a printer-friendly version  of my Web Dynpro views to enable users to get a printable report.
    Now my problem is reading out the property-files generated by Web Dynpro with a java utility class.
    I think my attempt fails, because those property files for each view follow a naming convertion, which is like this:
    com.mypackage.mysubpackage.MyViewName.wdview_<Locale>.properties
    so when I try to access those property files with a call like
          Locale sessionLocale = WDResourceHandler.getCurrentSessionLocale();
          ResourceBundle resourceHandler = ResourceBundle.getBundle("com.mypackage.mysubpackage.MyViewName.wdview",sessionLocale);
    I guess the resourceHandler thinks "wdview" is the name of my resource and tries to resolve this name to a propery file such as wdview_de.properties.
    Am I missing something? Did anyone experience a similar behaviour or knows a working work-around?
    My SAP-solution would be to duplicate code (...) which is no fun and a real pain when application texts are changed on later development stages...
    Thanks for your support!
    regards,
    Christian

    Hi,
    found the solution myself, so here is my insight:
    The view-specific property-files generated by the XLF-files can not be accessed by Java as the  ResourceBundle.getBundle(...) method replaces all dots in the name of the Resource file according to this:
    It generates a path name from the candidate bundle name by replacing all "." characters with "/" and appending the string ".properties".
    (see SUN Java API docs [ResourceBundle|http://java.sun.com/j2se/1.4.2/docs/api/java/util/ResourceBundle.html])
    Thing is the generated property-files of the views get merged into property files for the component. So if your component sports 12 views with one xlf-  and property-file each, there is gonna be one big property-file for the whole component, that resides in your wdp folder.
    Accessing this file is pretty straight-forward, the naming is like "Resource" + <Name of Component> +".properties".
    Maybe someone else struggles with WDJ and needs this.
    regards,
    Christian
    Edited by: Christian Henn on Jan 17, 2008 6:01 PM
    Edited by: Christian Henn on Jan 18, 2008 11:06 AM

  • Problem  while reading XML file from Aplication server(Al11)

    Hi Experts
    I am facing a problem while  reading XML file from Aplication server  using open data set.
    OPEN DATASET v_dsn IN BINARY MODE FOR INPUT.
    IF sy-subrc <> 0.
        EXIT.
      ENDIF.
      READ DATASET v_dsn INTO v_rec.
    WHILE sy-subrc <> 0.
      ENDWHILE.
      CLOSE DATASET v_dsn.
    The XML file contains the details from an IDOC number  ,  the expected output  is XML file giving  all the segments details in a single page and send the user in lotus note as an attachment, But in the  present  output  after opening the attachment  i am getting a single XML file  which contains most of the segments ,but in the bottom part it is giving  the below error .
    - <E1EDT13 SEGMENT="1">
      <QUALF>001</QUALF>
      <NTANF>20110803</NTANF>
      <NTANZ>080000</NTANZ>
      <NTEND>20110803<The XML page cannot be displayed
    Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
    Invalid at the top level of the document. Error processing resource 'file:///C:/TEMP/notesD52F4D/SHPORD_0080005842.xml'.
    /SPAN></NTEND>
      <NTENZ>000000</NTENZ>
    for all the xml  its giving the error in bottom part ,  but once we open the source code and  if we saved  in system without changing anything the file giving the xml file without any error in that .
    could any one can help to solve this issue .

    Hi Oliver
    Thanx for your reply.
    see the latest output
    - <E1EDT13 SEGMENT="1">
      <QUALF>003</QUALF>
      <NTANF>20110803</NTANF>
      <NTANZ>080000</NTANZ>
      <NTEND>20110803</NTEND>
      <NTENZ>000000</NTENZ>
      <ISDD>00000000</ISDD>
      <ISDZ>000000</ISDZ>
      <IEDD>00000000</IEDD>
      <IEDZ>000000</IEDZ>
      </E1EDT13>
    - <E1EDT13 SEGMENT="1">
      <QUALF>001</QUALF>
      <NTANF>20110803</NTANF>
      <NTANZ>080000</NTANZ>
      <NTEND>20110803<The XML page cannot be displayed
    Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
    Invalid at the top level of the document. Error processing resource 'file:///C:/TEMP/notesD52F4D/~1922011.xml'.
    /SPAN></NTEND>
      <NTENZ>000000</NTENZ>
    E1EDT13 with QUALF>003 and  <E1EDT13 SEGMENT="1">
    with   <QUALF>001 having almost same segment data . but  E1EDT13 with QUALF>003  is populating all segment data
    properly ,but E1EDT13 with QUALF>001  is giving in between.

  • Read out loud does not work on Adobe Reader XI.  Does anyone know how to fix this problem?

    Does anyone know how to repair the Read Out Loud problem with Adobe Reader XI?

    Hi thomash,
    Are you running into this problem with all PDFs, or just a select few? If the PDF was created from a scan, and OCR wasn't performed (so there's no "live" text), then there wouldn't be anything to read aloud.
    If the issue occurs regardless of the PDF you have open, has anything changed on your system since Read Out Loud worked for you?
    Best,
    Sara

  • Adobe Reader XI Read Out Loud problem

    I'm using Windows 8 and Adobe Reader XI, but the PDF documents won't 'read' when I activate Read Out Loud.  What am I doing wrong?

    Hi thomash,
    Are you running into this problem with all PDFs, or just a select few? If the PDF was created from a scan, and OCR wasn't performed (so there's no "live" text), then there wouldn't be anything to read aloud.
    If the issue occurs regardless of the PDF you have open, has anything changed on your system since Read Out Loud worked for you?
    Best,
    Sara

  • Adobe Reader X Read Out Loud Problem

    I had the previous version of Adobe Reader, and it had a problem. About ten seconds after I opened it, it would pop-up a error window and crash.
    Naturally, I uninstalled and then installed Adobe Reader X, which looks great, but when I tell him to read out loud something, it scrolls up to the top of the page\document, as if trying to read it, but won't play a sound. It moved down a single line, and then up again, and just kept on.
    I tryed it on several different documents, with different fonts, all supported, and to no good.
    I work a lot with Adobe Reader and PDFs, and would like to get a quick answer.
    Looking forward for an answer,
       lakerking008

    Same for me. Adobe Reader 10, no updates, no change after uninstall/reinstall. I am using Windows 7 and Microsoft narrator voices work in other applications. Even after copying text to Word, verifying that it is letter by letter typed and choosing a recommended font, then saving as a .pdf and reopening in Adobe Reader X.It also does not matter if I select the text or not.
    Gives me the option to "activate" with all other options greyed out. When activated, the other options become available but there is no voice. If I choose "read to end of document" Adobe Reader crashes.

  • Read out Loud problem in Adobe Reader X

    I tried the Read out loud feature of Adobe Reader X, but it does not seem to be working.
    I am using Adobe Reader X on windows XP sp3
    when i click activate read out loud
    it gives me to more options in the view menu to read current page and read entire file to the end
    when I click either option, the option to pause and stop appears in the view menu but i dont hear anything.
    what should I do?

    Thanks for the response.
    Yes, this is mostly pie in the sky.  We're interested in taking the
    audio from a document read aloud by Adobe Reader and converting it into
    a format that can be burned to CD. I'm assuming that we would simply have to record the aloud reading--but I was wondering if Reader gurus might have a better approach.
    J

  • Read out loud problem

    I am having trouble with the read out loud option. When I open a pdf with adobe reader & try to use the read out loud option it says "warning blank page" even though there is content there. Please help!!!!!

    Hi,
    You may try suggestions from this link: Read Aloud in Adobe Reader XI
    Also i would suggest to install latest updates pending for Acrobat/Reader.
    Regards,
    Ajlan Huda.

  • Problem when decrypting an encrypted xml data with arabic data

    Hi all
    I have problem in decryption an encrypted Xml file. because my Xml file contains utf-8 characters, this problem occurs. after many proccess on Xml data the following code throws an Exception:
    try {
    // Works if the content is a single child element.
    byte [] a = decbit.getBytes("UTF-8");
    ByteArrayInputStream bais2 = new ByteArrayInputStream(a);
    Document decdoc = docBuilder.parse(bais2);
    Node decNode =
    encDoc.importNode(decdoc.getFirstChild(), true);
    edata.getParentNode().replaceChild(decNode,edata);
    }catch(org.xml.sax.SAXParseException spe) {
    //In case the content is plain text
    //or a group of child elements
    Text decText = encDoc.createTextNode(decbit);
    edata.getParentNode().replaceChild(decText,edata);
    decString = (getString((XmlDocument)encDoc));
    at the line with code "Document decdoc = docBuilder.parse(bais2); " an Exception occurs with message :
    org.xml.sax.SAXParseException: Illegal character at end of document, &#x3c;.
    whereas when I debug the project the filed "decbit", contains correct data. any way, in order to the exception, the control move to "catch" block and create a Text Node but the problem is the replaced data is like this:
    <id root="588588588" extension="" displayable="false" /><beneficiaryOf typeCode="BEN">
    <policyOrAccount classCode="COV" moodCode="EVN">
    <id xsi:type="II" root="855855855" extension="" displayable="false" />
    <author typeCode="AUT">
    <carrierRole classCode="UNDWRT">
    <id root="6548888888" extension="" displayable="false" />
    </carrierRole>
    </author>
    </policyOrAccount>
    </beneficiaryOf>
    as you can see, tha "<" characters are < and the ">" characters are >
    this really exhausted me, please help me out.
    thank you, any help will be appreciated
    regards
    Mohammad

    Hi Naveen,
    In sxmb_moni the content transmitted to the adapter(RFC)is as follows
    <?xml version="1.0" encoding="UTF-8" ?>
    - <ns:ZRFID_EQUIP xmlns:ns="urn:sap-com:document:sap:rfc:functions">
    - <RECORDS>
    - <item>
      <FLOC>f1-01-01</FLOC>
      <RFID_NO>I006</RFID_NO>
      </item>
    - <item>
      <FLOC>f1-01-02</FLOC>
      <RFID_NO>I002</RFID_NO>
      </item>
    - <item>
      <FLOC>f1-01-03</FLOC>
      <RFID_NO>I003</RFID_NO>
      </item>
    - <item>
      <FLOC>f1-01-04</FLOC>
      <RFID_NO>I004</RFID_NO>
      </item>
    - <item>
      <FLOC>f1-01-05</FLOC>
      <RFID_NO>I005</RFID_NO>
      </item>
    - <item>
      <FLOC>f1-01-06</FLOC>
      <RFID_NO>I001</RFID_NO>
      </item>
      </RECORDS>
      </ns:ZRFID_EQUIP>
    At r/3 side the field floc and rfid_no gets mapped to floc which is of char30
    eg floc=f1-01-01I006
       rfid_no=

  • How to read  and write XML in java

    I have a code that reads a large XML file, splits it into smaller files, filters and then writes it into a new XML file. My problem is that I had coded the input file name into the code, so that only the specified file can be read. How can I rewrite my code to be able to take any input xml and perform the same operation? Here's a portion of my code below:
                            File file = new File("c:\\APAdjustmentJVDoc_FINAL.xml");
                        output = new BufferedWriter(new FileWriter(file));
                        for (int i = 1; i < 79; i++) {
                             fIStream = new FileInputStream("c:\\APAdjustmentJVDoc_new" + i + ".xml");
                             loRead = new InputStreamReader(fIStream);
                             doc = XMLUtil.transformToNode(loRead, false);
                             System.out.println("Reading from file " + "c:\\APAdjustmentJVDoc_new" + i + ".xml");
                             writeFile(doc, docIdList, output);
                             fIStream.close();
                             loRead.close();
                        System.out.println("Output file complete");
                   } catch (Exception e) {
                        e.printStackTrace();
                   } finally {
                        if (output != null) {
                             output.close();
                        if (fIStream != null) {
                             fIStream.close();
              } catch (Exception e) {
                   e.printStackTrace();
                 

    You need to pass your filename String as a parameter to your functionality. It depends how you're currently set up though. We can't really see the top of your call so it's difficult to determine what you are calling and we don't really know from where you're calling either.
    If you're running standalone, then on launch of the application, you can feed in a file name as an argument that you can read in in String args[] in the main function and pass down to your XML splitter.
    If you're a method in a class that's part of a bigger pile, you can feed the file name as a String to the method from wherever you call from if it makes sense architecturally.
    You might also want to pass down a File object if that makes sense in your current code (i.e. if you're using your file for other purposes prior to the split, to avoid recreating closing/opening for no reason).
    Depends what you're trying to do. If I put together a piece like this, I would probably create an <yourcurrentrootpackage>.xml.splitter package.
    Also, on a side note, you're problem isn't really reading and writing XML in java, but seems more to be making your functionality generic so that any XML file can be split with your code.
    Regards
    JFM

  • Read data From XML

    hi
    I am new to XML.I want to read data from XML input ....For test purpose i have writte following
    procedure , but when i print output value it shows ...NO ROWS SELECTED
    Actually i want to read [ trd_relate ] value from following XML Input
    '<ROOT><TRD trd_relate = "somevalue" trd_mainid = "152" trd_rate = "0.0000"/></ROOT>'
    plese help me to solve this problem.
    Thanks
    create or replace procedure xml_test1(p_xml clob,rc1 in out mypkg.rc)
    as
    aaa xmltype;
    begin
    aaa :=xmltype(p_xml);
    open rc1 for
    SELECT extractValue(aaa, '/ROOT/TRD/trd_mainid') SOME_NAME
    FROM table(XMLSequence(extract(aaa, '/ROOT/TRD/trd_mainid'))) ResultSet;
    end xml_test1;
    var a refcursor;
    exec xml_test1('<ROOT><TRD trd_relate = "" trd_mainid = "152" trd_rate = "0.0000"/></ROOT>',:a);
    print a;
    **************************************

    Hi,
    try this:
    1 create or replace function test(xml xmltype, qry varchar2) return varchar2 is
    2 xx varchar2(100);
    3 begin
    4 select extractValue(xml, qry)
    5 into xx
    6 from dual;
    7 return xx;
    8* end;
    SQL> /
    Function created.
    SQL> variable out varchar2(100)
    SQL> exec :out := test(xmltype('<ROOT><TRD trd_relate = "somevalue" trd_mainid = "152" trd_rate = "0.0000"/></ROOT>'), '/ROOT/TRD/@trd_relate');
    SQL> print out
    OUT
    somevalue
    Bartek

  • Java XML-Reader (SAX)--How to read and display xml-element-data???

    hello all,
    i would like to display just some xml-data
    Which methods in java should i use to select just one character-data of this (for example: "deu" from the element <Language> or the attribut "version" of the element <catalog>).
    Here is the XML-document i want to parse and display it with System.out.print() :
    <BMECAT version="1.2">
         <HEADER>
              <GENERATOR_INFO>
                   e-proCat 2.1, e-pro solutions GmbH
              </GENERATOR_INFO>
              <CATALOG>
                   <LANGUAGE>deu</LANGUAGE>
                   <CATALOG_ID>Katalog 01</CATALOG_ID>
                   <CATALOG_VERSION>001.000</CATALOG_VERSION>
                   <CATALOG_NAME>ETIM</CATALOG_NAME>
                   <DATETIME type="generation_date">
                        <DATE>2002-05-22</DATE>
                   </DATETIME>
                   <TERRITORY>DE</TERRITORY>
                   <CURRENCY>EUR</CURRENCY>
                   <MIME_ROOT>ETIM-Daten</MIME_ROOT>
              </CATALOG>
    </HEADER>
    </BMECAT>
    Here is the java application i wrote and which doesn t work:
    import org.apache.xerces.parsers.SAXParser;
    import org.xml.sax.Attributes;
    import org.xml.sax.ContentHandler;
    import org.xml.sax.Locator;
    import org.xml.sax.SAXException;
    import org.xml.sax.XMLReader;
         public class XmlLeser implements ContentHandler {
    public XmlLeser(String fileName) {
    try {
    XMLReader myParser = new SAXParser(); // SAXParser (Xerces)
    myParser.setContentHandler(this);           
    myParser.parse(fileName);      } catch (Exception e) {
         System.out.println("Erreur " + e);     }
    }// End of constructor
    public void startDocument() {
         System.out.println(" start to parse " );
    } // startDocument()
    public void endDocument() {
    System.out.println(" End of Parse ");
    } // endDocument()
    public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
         System.out.println(localName) ;
    public void endElement(String namespaceURI, String localName, String qName) throws SAXException {           
    }// Endelement()
    public void characters(char ch[], int start, int length) {
    } // endCharacters(char[],int,int);
    public void processingInstruction(String target, String data) {
    } // processingInstruction(String,String)
    public void ignorableWhitespace(char ch[], int start, int length) {
              characters(ch, start, length);
    } // ignorableWhitespace(char[],int,int);
    public static void main(String args[]) {
    String xmlFileName = "";
    if (args.length == 0) {               
    System.out.println("Usage::java XmlLeser path/xmlFilename");
    System.exit(0);      } else {
    xmlFileName = args[0];
    XmlLeser pux = new XmlLeser(xmlFileName);
    }// end main()
    }//endClass

    You need to pass your filename String as a parameter to your functionality. It depends how you're currently set up though. We can't really see the top of your call so it's difficult to determine what you are calling and we don't really know from where you're calling either.
    If you're running standalone, then on launch of the application, you can feed in a file name as an argument that you can read in in String args[] in the main function and pass down to your XML splitter.
    If you're a method in a class that's part of a bigger pile, you can feed the file name as a String to the method from wherever you call from if it makes sense architecturally.
    You might also want to pass down a File object if that makes sense in your current code (i.e. if you're using your file for other purposes prior to the split, to avoid recreating closing/opening for no reason).
    Depends what you're trying to do. If I put together a piece like this, I would probably create an <yourcurrentrootpackage>.xml.splitter package.
    Also, on a side note, you're problem isn't really reading and writing XML in java, but seems more to be making your functionality generic so that any XML file can be split with your code.
    Regards
    JFM

  • Not able to Read Blob ( BlobDomain) Xml Data from DB

    I am trying to read a BLOB file from Data base with the below code . However , i am facing 2 challenges - which i need ur help..
    1. the data is not in readable format , may be i am missing some more code or encoding somewhere . ( this is how data is printing-- �B�...........)
    2. Throwing an exception in the end
    The Blob Data types appears as BlobDomain in the entity defination . My jdev is 11.1.1.5
    +{+
    +..............+
    oracle.jbo.domain.BlobDomain  blobDomainXml = (BlobDomain)r.getAttribute("Document");
    System.out.println(" XML Out Put = "blobDomainXml);+
    +}+
    public ViewObject getBlobObject(){
    return (ViewObjectImpl)findViewObject("getBlobObject1");
    below is exception after the call ---
    Caused by: java.lang.NullPointerException
         at oracle.jbo.server.ViewRowSetIteratorImpl.getViewObject(ViewRowSetIteratorImpl.java:238)
         at oracle.jbo.server.ViewRowSetIteratorImpl.getSyncLock(ViewRowSetIteratorImpl.java:178)
         at oracle.jbo.server.ViewRowSetIteratorImpl.hasNext(ViewRowSetIteratorImpl.java:1904)
         at com.stryker.gtc.view.bean.LoginPageName.getBlob(LoginPageName.java:243)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.sun.el.parser.AstValue.invoke(Unknown Source)
         at com.sun.el.MethodExpressionImpl.invoke(Unknown Source)
         at org.apache.myfaces.trinidadinternal.taglib.util.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:53)

    The Blob xml has used some encoding . If i use the below italic code in main class , i can get the proper xml . However , It uses the blob resultset but I get exception if i try with ADF blob domain .
    below is the code in a simple main method class and gives me the desired xml .
    ResultSet rset = statement.executeQuery("Select * from XML_DOCUMENT where DOCUMENT_ID=(Select DOCUMENT_ID from DOCUMENT_DLV_MSG_REF where MESSAGE_GUID = (Select MESSAGE_GUID from DLV_MESSAGE \n" +
    "where CIKEY = (Select CIKEY from CUBE_INSTANCE where CMPST_ID='1931038')))");
    +try {+
    XMLDOMImplementation domimpl = new XMLDOMImplementation();
    +while (rset.next()) {+
    BinXMLProcessor proc =  BinXMLProcessorFactory.createProcessor()  ;
    BinXMLStream inpbin = proc.createBinXMLStream(rset.getBlob("DOCUMENT"));
    BinXMLDecoder dec = inpbin.getDecoder();
    InfosetReader xmlreader = dec.getReader();
    XMLDocument doc = (XMLDocument)domimpl.createDocument(xmlreader);
    doc.print(System.out);
    +}+
    +} catch (Exception e) {+
    System.out.println(" Exception ="e);+
    +}+
    But , In ADF we have Blob Domian in the entity defination , auto generated ...
    Row r = iter.next();
    oracle.jbo.domain.BlobDomain blob = (*BlobDomain*)r.getAttribute("Document");
    try
    XMLDOMImplementation domimpl = new XMLDOMImplementation();
    BinXMLProcessor proc = BinXMLProcessorFactory.createProcessor() ;
    BinXMLStream inpbin = proc.createBinXMLStream(blob.getInputStream());
    BinXMLDecoder dec = inpbin.getDecoder();
    InfosetReader xmlreader = dec.getReader();
    now in the above higlighted code I get java.lang.IllegalArgumentException . I do not find a way to convert BlobDomain to blob . even no decoder in blob Domain .
    May be you can help ..
    Edited by: Amitava Biswas on Sep 12, 2012 11:13 AM

  • How to read out and modify text parts in a pdf-document?

    Hello,
    My problem is the following: I want to read out text passages of an existing pdf-file, compare them with files in an odbc-database and write down the results of that comparison in the same pdf-file. The term is: Read out a number in the file, search the database for the matching user-name, generate a field in the pdf and write down the search results in that.
    i have read that this could be possible with acrobat...my version is an acrobat 9 pro extended...
    could someone please tell me how to do that?
    big thanks

    As the definition of “color” vs. “black and white” differ by context – there aren’t any that I am aware of.
    You can, however, use the Preflight feature built into Acrobat to identify whatever you wish…

Maybe you are looking for

  • Syncing with iTunes over wifi doesn't work

    My iTunes sometimes does not recognize my iPhone... but sometimes it does. When I click to sync it will start but it will get an error eventually like "Sync failed to start" or "Unknown error -50". I am not sure why iTunes will not sync. It used to w

  • Section Break conflicts with Dynamic Header in RTF which loads XML data

    Hi, I have dynamic header in my rtf file which loads data from XML generated by rdf file. I have section break on start group of body. but it does not display dynamic header value. If i remove section break then it display dynamic header. I have to d

  • What is the best edge to edge glass screen protector for iPhone 6

    What is the best edge to edge glass screen protector for iPhone 6

  • Excise for STO for Storage location

    I have a requirement whre i want to create Excise invoice for STO between storage location, as i already raised this doubt in SD community, but did not got the satisfaction. As i want to use the same excise NUMBER series which is assingned to excise

  • Schedule and Email a Report in 10gAs

    Hi all, I have a report in 10g. This report should run every 1st of every month automatically and the output in pdf has to be sent to some people via email. Provide me some documentation on this. Please help me,