Read and parse XML

Hi all,
is there some procedure or function or whatever I can use to read and parse an XML file into Oracle?
The XML contains 30+ Megs of data, which would represent data in 10+ tables if you would convert it into flat files.
I know I can read the XML and save it line by line in a table, but I do not want to parse it myself. It would be cool if there was a tool or so that would read the dtd definition of the XML, then read the XML data, parse it and create temporary tables with the flat content of the xml (can you code object oriented with PL/SQL? this would even be cooler!).
Does someone have an idea how to do that?
Thanks,
Steff

Wow, I've never tried to parse an XML file quite that large
before. Does it contain a bunch of encoded binary data, or does it
have houndreds of thousands of xml-nodes?
In any event, I do have one thought:
Do you need absolutely everything in the file? If you only
need access to a small portion of it, it would be worth your while
to pull out only the "stuff" that you need before you parse it. You
could use regular expressions to strip out things you don't need,
or to pull out only the stuff you do need.
The more you can minimize the "parse" effort the better off
you'll be.
Alternatively, if it's a file describing many "records" of
the same type, it would be best if you could "chunk" the file and
parse each record individually.

Similar Messages

  • Best way to read and parse XML to multiple tables

    This is first time using XML input file for JDev ADF 10.1.3.3 application. We are trying to develop an XML API that the application will read and process. A simple XML record would have field tags for table AA which has 1 to many tags for table BB. Table BB contains 0 to many tags for tables: CC, DD, and EE. Naturnally, the database is relational and there exist Foreign Keys for the Master-Detail relationships that are represents as View Objects in the JDev application.
    What is the best way for us to design and code this API?

    Hi,
    I don't really see any better options for SharePoint. SharePoint use other production called 'Office Web App' to allow users to view/edit Microsoft Office documents (word, excel etc.). But the web version of excel doesn't support that much records as well
    as there's size limitations (probably the default max size is 10MB).
    Regarding second problem, I think you need some custom solutions (like a SharePoint timer job/webpart ) to read and present data.
    However, if you can reduce the excel file records to something near 16k (which is supported rows in web version of excel) then you can use SharePoint Excel service to refresh data automatically in the excel file in SharePoint from some external sources.
    Thanks,
    Sohel Rana
    http://ranaictiu-technicalblog.blogspot.com

  • How to read and parse a remote XML file with Java

    Hi.
    Using J2SE v1.4.2, I'd like to read and parse a remote file:
    http://foo.com/file.xml
    Is it possible with Java? I'd be extremely grateful if someone could provide me any webpage showing a very simple code.
    Thank you very much.

    How about the following?
         import java.io.InputStream;
         import java.net.URL;
         import javax.xml.parsers.DocumentBuilder;
         import javax.xml.parsers.DocumentBuilderFactory;
         import org.w3c.dom.Document;
         public static void main(String[] args) throws Exception {
              DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
              DocumentBuilder db = dbf.newDocumentBuilder();
              URL url = new URL("http://foo.com/file.xml");
              InputStream inputStream = url.openStream();
              Document document = db.parse(inputStream);
              inputStream.close();
         }-Blaise

  • 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

  • Error in retrieving and parsing XML File

    Hi Folks
    I am Working on People centric user interface, While i am custimizing a application in Business application Builder i am getting this error
    " Error in retrieving and parsing XML File "
    can any body look on this and give me the solution
    it will be rewarded
    Regards
    M.S.Kumar

    Hello,
    As mentionned by SAP_TECH, avoid to use the BAB.
    Go to CRMC_BLUEPRINT_C and use the different option in the menu to customize the field group, toolbar group, events, ...
    Use the PCUI cookbook to find your way.
    Regards,
    Fred

  • How to Read and Write .XML datas   (HELP Plz...)

    hai everybody
    how to read and write xml datas... plz give clean and simple example..
    bcoz me want to produce such type of module...
    if any one help me .. thats the only way me laid in software ladder
    plz....
    thank u in advance

    thank u for giving idiot..
    but before posting i search in google also..
    but i cant get what me expect..
    thus i posted...
    then who is ................?
    sorry javacoder01
    // plz help me
    Message was edited by:
    drvijayy2k2

  • How to read and write Xml file at client side using JavaScript !

    Hello,
    i am new to javascript.
    I have requirement to read and update XML file at client side.
    Will you please guide what could be the best way to read and update XMl file using javascript.
    Thanks,
    Zuned

    This is a Java forum,not a Javascript forum. Maybe you should ask here [http://www.webdeveloper.com/forum/forumdisplay.php?forumid=3&s|http://www.webdeveloper.com/forum/forumdisplay.php?forumid=3&s].

  • How to read and parse a comma delimited file?  Help

    Hi, does anyone know to read and parse a comma delimited file?
    Should I use StreamTokenizer, StringTokenizer, or the oro RegEx packages?
    What is the best?
    I have a file that has several lines of data that is double-quoted and comma delimited like:
    "asdfadsf", "asdfasdfasfd", "asdfasdfasdf", "asdfasdf"
    "asdfadsf", "asdfasdfasfd", "asdfasdfasdf", "asdfasdf"
    Any help would be greatly appreciated.
    thanks,
    Spack

    import java.util.*;
    import java.io.*;
    public class ResourcePortalParser
        public ResourcePortalParser()
        public Vector tokenize() throws IOException
          File reportFile = new File("C:\\Together5.5\\myprojects\\untitled2\\accessFile.txt");
         Vector tokenVector = new Vector();
          StreamTokenizer tokenized = new StreamTokenizer(new FileReader(reportFile));
         tokenized.eolIsSignificant(true);
              while (tokenized.nextToken() != StreamTokenizer.TT_EOF)
                   switch(tokenized.ttype)
                        case StreamTokenizer.TT_WORD :
                        System.out.println("Adding token - " + tokenized.sval);
                             tokenVector.addElement(tokenized.sval);
                             break;
              return tokenVector;
    [\code]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • 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

  • Loading and parsing XML files

    I am currently working on an application in which I have a XML file that is 1.5 mb and has 1100 records that I need to load and parse. Loading takes less than a minute, but when I try to parse it with the DOM parser it's taking too much time. I am trying to put it into an array and then display it as if I'm tied to a database. I need a different approach. Does anyone have any experience and insight with the DOM parser? Would the SAX parser be a better way to go, why and how?

    You can use SAX... but SAX is good only if you want to read the data once.
    If you want to use the same data again and again then you might have to parse the file again... which prooves expensive.
    DOM will take too much of memory and CPU time.
    Have you tried using JDOM ? it is a new kind of a XML parsing utility that is quite lightweight and has good api to recurse the JDOM tree also.
    check it out at
    http://www.jdom.org.
    hope this helps.
    regards,
    Abhishek.

  • Loading and parsing XML

    what is the best method for loading external XML (with
    inherent HTML) content into Flash and into the TextArea component?
    here is the requirement:
    i have an image loader and a TextArea together on the screen.
    a "story" is loaded which will present a series of images (in the
    image loading) associated with a corresponding text (in the
    TextArea). a "story" has multiple image/text sections that are
    navigatied through with FRWD/BACK buttons. any given section can
    also have multiple sub-sections or "frames".
    here is a diagram of the flow (in this case there would be 5
    click throughs: 5 text/image sequences, but all contained only
    within 4 sections):
    http://jalaka.com/lab/ia/story_nav.jpg
    below is my proposed sample XML structure. i want Flash to
    recognize how many sections and frames within sections there are in
    each story XML document - in order to generate a corresponding
    navigation structure (a tab for each section). HTML content will be
    immediate availble to loadinto TextArea as user move forward in
    sequence with nav. and images references can also be preloaded into
    available MC containers to be swapped into place as user navigates
    forward in sequence. also need to read and store attributes for
    each node in the XML to come up in MCs in sequence. and must also
    be able to parse XML in a way to place simple HTML formatted
    content (within XML) into the TextArea.
    would Arrays be used?
    <story title = "Story Title">
    <section num = "1" title = "Section One Title" >
    <frame image = "1.jpg" caption = "caption text
    here"><b>Content</b><br><br>content
    content content</frame>
    </section>
    <section num = "2" title = "Section Two Title" >
    <frame image = "1.jpg" caption = "caption text
    here"><b>Content</b><br><br>content
    content content</frame>
    <frame image = "2.jpg" caption = "caption text
    here"><b>Content</b><br><br>content
    content content</frame>
    </section>
    </story>

    Placing the XML into an array is a great plan. What you want
    is each array element to be an object containing the section data.
    Another plan is to use a List or Combox component. Again each
    data property element would be an object containing the section
    data.

  • Anyone have example to read and write XML to/from file

    I am writing a swing utility and need to save and read data in XML. I have looked around google, but the examples are just confusing me.
    Jonathan

    Do these xml docs have dtd's? And specific DOM implementation needs or just a custom xml?
    I have some examples in http://cvs.sourceforge.net/viewcvs.py/mathml-x/mathml-x/src/com/neuralworks/physics/Academy.java?view=markup
    follow openMenuItemActionPerformed and openFEMMLDocument(String filePath). Look for DocumentBuilder
                DocumentBuilderFactory factory =
                DocumentBuilderFactory.newInstance();
    /*            factory.setAttribute("element.factory",
                                     ELEMENT_FACTORY);
                factory.setAttribute("attribute.factory",
                                     ATTR_FACTORY);
                DocumentBuilder builder = factory.newDocumentBuilder();
                //builder.setEntityResolver(new X3DEntityResolver());
                //builder.setErrorHandler(new X3DErrorHandler());
                femDoc = findXMLFile(builder, filePath);
                org.w3c.dom.Element docElement=femDoc.getDocumentElement();
                javax.swing.tree.DefaultMutableTreeNode dmtn=new javax.swing.tree.DefaultMutableTreeNode("FEMML");
                javax.swing.tree.DefaultMutableTreeNode svgChild=new javax.swing.tree.DefaultMutableTreeNode(docElement.getNodeName());
                //System.out.println(svgDocument.getTitle()+" nv "+svgSVGElement.getNodeValue());
                //recurseDOM2TreeNodes(svgChild, docElement.getChildNodes());
                dmtn.add(svgChild);
                JTree tree=new JTree(new javax.swing.tree.DefaultTreeModel(dmtn));
                tree.setRootVisible(true);
                tree.setShowsRootHandles(true);
                tree.setEditable(true);
                //try
                    //X3DTreeAdapter x3dTreeAdapter=new X3DTreeAdapter(x3dDTDParser.parse());
                    //org.web3d.x3d.dom.swing.DOMTreeCellEditor domTreeCellEditor=new org.web3d.x3d.dom.swing.DOMTreeCellEditor();
                    //tree.setCellEditor(domTreeCellEditor);
                    //org.web3d.x3d.dom.swing.DOMTreeCellRenderer domTreeCellRenderer=new org.web3d.x3d.dom.swing.DOMTreeCellRenderer();
                    //domTreeCellRenderer.addMouseListener(x3dTreeAdapter);
                    //domTreeCellRenderer.addMouseMotionListener(x3dTreeAdapter);
                    //tree.setCellRenderer(domTreeCellRenderer);
                    //tree.addMouseListener(x3dTreeAdapter);
                    //tree.addMouseMotionListener(x3dTreeAdapter);
                    academicSplitPane.setLeftComponent(new JScrollPane(tree));Lot of commented out stuff I need to clean up. There are other examples of opening specific xml docs that have special DOM implementations; svg and mathml for example.
    For saving I use xslt with an identity transform to go from an in memory DOM source to an xml document on disk.
    Follow the saveAs(String filePath) method and the identity.xsl is http://cvs.sourceforge.net/viewcvs.py/mathml-x/mathml-x/stylesheets/identity.xsl?rev=1.2&view=markup

  • Downloading and parsing XML during preload

    Apologies if this topic has already been covered but the
    search function on the forums doesn't appear to be working for me.
    My problem is this. I have a flex app that needs to download
    a couple of xml files during initialization that are approximately
    2-3 MB each. I'd like for the progress bar to continue showing
    until the files are downloaded and parsed and only after the files
    are downloaded and parsed, would the components start to be
    rendered since some of them will require the files to determine
    their look and feel.
    Any ideas or places I should look to in order to figure this
    out?
    Thanks
    Sang

    Greg_B,
    You could try and access the XML file via a file:// URI rather than an http:// one - this would not need the server to be started in order to get the xml/dtd loaded. You know the relative path to the dtd and xml files, and you can create a File object from there, so you can parse the xml file that way if you like.
    Here's some code to help:
    String filename = getServletContext().getRealPath("myXML.xml");
    You can then pass the filename string as a parameter to the XML (I'm assuming you're using DOM but if you aren't I think you'll still get my point) parse method.
    You can do all of this in the servlet's init() method, so it'll do that before it all loads up.
    Hope it helps
    Daniel

  • How to get and parse xml input parameter?

    Hi,
    If one transaction input parameter is xml string, like as below.
    <a>
    <b>
        <c>1</c>
        <d>2</d>
    </b>
    <b>
        <c>3</c>
        <d>4</d>
    </b>   
    </a>
    If I would like to get each element (maybe by repeater action), how to do that?
    Thanks!

    Hi,
    You must convert the string into xml with necessary action block. (XML Functions --> String to XML Parser)
    Then you must put a repeater after converter action and you must set Xpath expression for repeater (configuration) like below:
    String_To_XML_Parser_0.Output{/ARef/BRef}
    after repeater you can use values like below:
    Repeater.Output{/BRef/c}
    Repeater.Output{/BRef/d}
    Regards.

  • How to Read and Generate XML file from java code.

    hi guys,
    how to read the xml file (Condition :we know only DTD or Shema only).
    How to Generate the new xml file ?(using Shema )
    And one more how directly Generate the xml from DB?
    Pleas with code or any URL

    Using XMLbeans you can generate Java objects from an XSD schema (perhaps DTDs aswell)
    Then you can create an instance of the Document object and ask it to write itself.
    This will create an XML document complient to the schema.
    XMLBeans generates a "type" safe DOM where you can only ever have a structure compilent to you schema.
    matfud

Maybe you are looking for

  • Battery never stops charging....

    I have a Powerbook I got back in September of last year, and overall I've really enjoyed using it, but I have a somewhat unusual problem. I'm hoping that it's only my impatience and that there isn't really anything to worry about, but let me begin. I

  • Why ADF Business Components and TopLink

    Hi All, Why are there two types of components in Businses Tier? (ADF Business Components and TopLink). Even through there are other types, I can visualize the use of other components but ADF Business Components & TopLink seems to serve the same requi

  • Version 8 sharing with Version 7

    If I upgrade iTunes on my main computer to version 8, will I still be able to share my iTunes library with my other computer running iTunes version 7? I can't go any higher than OS 10.3.9 on that computer. Thanks so much if you can help me out!

  • Dynamic tables collide when adding rows

    Hi, I created two dynamic tables with buttons to add/remove/move rows. When I add rows, the table collides with the other one and overlays it. How can I manage that the other table (or content) of the PDF is moved automatically further down to avoid

  • Is it possible to tweek the camera settings (iso) in my touch?

    I used to get great photos from my touch but now they are sa grainy as, even in good light. the only other cause might be one or other of the apps I have installed...any clues???