DOM or SAX in parsing.Please GUIDE

If I have a huge document that I need to parse,
which is the recommended parser I shud use?
SAX or DOM.??
Isnt DOM impractical to use if the document fills
gigabytes?
Can some one please answer?

SAX reads through the document and sends you events of what is read.
SAX will never store any of the data which is read.
You can do whatever you like with these events.
DOM reads through the document and makes a memroy-model of the XML-file.
This will store the complete XML-document in memory.
Afterwards, you can browse this structered (in memory) data within your program.
There is a tradeof between DOM and SAX.
SAX has a smaller (constant) memory-usage (certainly with large XML-files),
and has a faster processing of the data.
But SAX delivers no real structured data and is only read in one direction.
SAX should be used when large files are read only once in a linear direction
and if the processing of the data does not rely to much on the structure of the data.
DOM has a larger memory-usage (certainly with large XML-files),
and has a slower processing of the data (due to the initial parsing of the file).
But DOM delivers real structured data which can be manipulated on the structure in any direction.
DOM should be used when smaller files are read, when many different processing-steps should
be performed on the data or when the processing of the data is heavily relying on the structure of the data.
remark that DOM is using SAX as the underlying mechanism for reading the data.
DOM will read the data using SAX and will build the in-memory structured model of the data
according to the SAX-events.
remark also that other solutions such as JDOM and minimal DOM's exist.
kind regards,

Similar Messages

  • XML parser used in Oracle...DOM or SAX?

    Hi,
    My db version:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE    11.2.0.1.0    Production
    TNS for Linux: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    Question:
    I get an XML feed and load it into a temporary table T1.
    My requirement is to load it in the exact sequence as I get the rows in xml and also populate a column in the temporary table as a sequence like 1 2 3 corresponding to the rows in the xml
    When I do load the xml, it gets loaded in same order the xml feed is sent. So no worries.
    But while I was researching I came to know that Oracle could use either DOM or SAX parser. If it uses SAX, then the order is maintained as in XML. But if DOM is used, the order wont be maintained.
    Please let me know, how I can ensure that the xml order is maintained as it is while loading into temp table.

    I apologize, here is more details
    {code}
    CREATE TABLE XMLTEMPTBL
      PARAM      NVARCHAR2(30 BYTE),
      PARAMORDERSEQ NUMBER(3)
    XML format:
    <?xml version="1.0"?>
    <ROWSET>
    <ROW>
    <PARAM1>abc</PARAM1>
    </ROW>
    <ROW>
    <PARAM2>def</PARAM2>
    </ROW> 
    <ROW>
    <PARAM3>ghi</PARAM3>
    </ROW> 
    <ROW>
    <PARAM4>jkl</PARAM4>
    </ROW>
    </ROWSET>
    PROCEDURE insertparams (p_xmldoc IN CLOB)
    IS    
      insctx   DBMS_XMLSTORE.ctxtype;
      ROWS     NUMBER;     
    BEGIN     
      /*inserting insdoc into a temp table*/
      insctx := DBMS_XMLSTORE.newcontext ('xmlTempTbl');
      ROWS := DBMS_XMLSTORE.insertxml (insctx, p_xmldoc);
      DBMS_XMLSTORE.closecontext (insctx);
    END;
    I want to insert into table this way:
    select * from xmltemptb;
    PARAM PARAMORDERSEQ
    abc 1
    def 2
    ghi 3
    jkl 4
    {code}
    My procedure is not 100% correct (but it gives an idea what code I am using to load into table), but I want to ensure the xml rows are loaded into the table in the same sequence.

  • Difference between DOM and SAX

    Difference between DOM and SAX

    a sax parser is event driven meaning it processes the xml as it sees it and then forgets about it.
    you have to implement what you want the parser to do wants it reaches a certain event
    dom on the other hand keeps the whole structure of the message in memory as a tree.
    so there are strengths and weaknesses in both.
    you have to evaluate what you need

  • How to remove element namespaces in XML file using DOM or SAX?

    Hi Guys,
    I developed a JAVA mapping in XI to add name spaces for XML file, after mapping,name spaces xmlns="http://www.mro.com/mx/integration" and xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" were added correctly, but for some nodes, such as <Header> and <Content>, a name space xmlns="" was added automatically.Please check below files to compare.
    It looks like be added automatically by XI. I didn't process anything for these nodes in JAVA program.
    Now the issue is, how can I remove these redundant namespaces? Such as xmlns="".
    Can I remove them using DOM or SAX in JAVA Mapping?
    Thanks in advance.
    ====>Original XML file
    <?xml version="1.0" encoding="UTF-8"?>
    <LLYLPPInterface language="EN">
       <Header>
          <SenderID>GBIP</SenderID>
          <CreationDateTime>2008-02-13T22:49:34-05:00</CreationDateTime>
          <RecipientID/>
          <MessageID/>
       </Header>
       <Content>
          <LLY-LPP>
             <INVOICE>
                <INVOICELINE>
                   <PONUM>4780000008</PONUM>
                   <POLINENUM>1</POLINENUM>
                   <INVOICEQTY>1</INVOICEQTY>
                   <LOADEDCOST>68</LOADEDCOST>
                </INVOICELINE>
             </INVOICE>
          </LLY-LPP>
       </Content>
    </LLYLPPInterface>
    ===>Target XML file after JAVA mapping
    <?xml version="1.0" encoding="utf-8"?>
    <LLYLPPInterface language="EN" xmlns="http://www.mro.com/mx/integration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
         <Header xmlns="">
              <SenderID>GBIP</SenderID>
              <CreationDateTime>2008-02-13T23:11:55-05:00</CreationDateTime>
              <RecipientID/>
              <MessageID/>
         </Header>
         <Content xmlns="">
              <LLY-LPP>
                   <INVOICE>
                        <INVOICELINE>
                             <PONUM>4780000008</PONUM>
                             <POLINENUM>0</POLINENUM>
                             <INVOICEQTY>1</INVOICEQTY>
                             <LOADEDCOST>68</LOADEDCOST>
                        </INVOICELINE>
                   </INVOICE>
              </LLY-LPP>
         </Content>
    </LLYLPPInterface>
    Edited by: Eddie Zhang on Feb 14, 2008 9:22 AM
    Edited by: Eddie Zhang on Feb 14, 2008 9:24 AM

    Hi Milan,
    Thanks for your replay.
    Actually when I used module XMLAnonymizerBean to convert namespaces, the header of XML, such as <?xml version="1.0" encoding="UTF-8"?> was converted to format <?xml version='1.0' encoding='UTF-8'?>, quote was converted to single quote. Although I set parameter anonymizer.quote = ", it still didn't work, single quote appeared instead of quote.
    I'm not sure why this happened. Can anyone help to clarify this?
    Thanks
    Edited by: Eddie Zhang on Feb 15, 2008 2:11 AM

  • Sax XML Parser? URLDecoder.decode bad in applet? Explorer Browser jvm?

    Ok, here it goes folks, I have a serious problem with Explorers jvm, I'm developing using jdk 1.3.1 to write swing applets, in anyevent little functions that I use will not work with Explorers Browser, for example, the Explorer JVM understands the Vector addElement function, but not the Vector add function? Also, It doesn't recognize the HashMap class? Ok, is there anyway to control the JVM used with Explorer? Ok, but here goes my real question?
    I am writing an applet/servlet that interfaces with an oracle database. The data is returned in the form of xml. We are using the Sax XML parser interface. The parser code previously in the servlet(server side) and worked fine, but I've now moved the parsing code to the applet side, however, it seems to not want to work on the applet side. It simply hangs? I think it's a jvm issue, I've been getting many hangs with seemingly standard classes and methods, such as URLDecoder.decode(). Anyone else run into this problem using the Sax XML Parser, I have no idea what classes in the SAX Parser could be giving us a problems, or if that is even my issue. Anyone else using SAX XML parsing in an applet with Explorer 5.5. or 5.0, please let me know, if you've had issues?
    Sorry, to be so long winded, and not explaining the problem very well.

    First, get Sun's Java Plug-in from http://java.sun.com/products/plugin/index-1.4.html
    and read up on how to make your browser use it instead.

  • DOM or SAX?

    Hi,
    I have a very simple XML document as below:
    <message>
    <content></content>
    <date></date>
    </message>
    All I want to do is retrieve the <content> and <date> elements. Should I be looking at using DOM or SAX?
    Thanks.

    public class MyParser extends DefaultHandler{
       private String content;    // to hold the content value
       private String date;       // to hold the date value
       private String nodeName;   // to hold the nodeName
       // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
       public MyParser(){ }
       // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
       public void parse(String xmldoc){
          try{
              XMLReader reader = XMLReaderFactory.createXMLReader(vendor);
              reader.setContentHandler(this);
              // for xml document pass in as a String
              InputSource inputSource = new InputSource(
                                         new StringReader(xmldoc));
              reader.parse(inputSource); 
              // comment out InputSource if you use a file instead and
              // change reader.parse(inputsource) to reader.parse(xmldoc)
          catch (Exception e) { System.out.println(e); }
          // you would probably be catching SAXException and IOException
          // but i use this to make it simplier
       // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
       public void startElement(String ns, String name, String qName,
                                Attributes atts) throws SAXException {
           nodeName = name;
       // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
       public void characters(char[] ch, int start, int length)
                                          throws SAXException {
          if (nodeName.equals("content")
              content += new String(ch, start, length);
          else if (nodeName.equals("date")
              date += new String(ch, start, length);
       // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        public void endElement(String ns, String name, String qName)
                                               throws SAXException {
            if (name.equals("content"){
                   System.out.println("Content value is = " + content);
                content = ""; 
            else if (name.equals("date")){
                   System.out.println("Date value is = " + date);
                date = "";
            else if (name.equals("message")){
                System.out.println("End of XML doc and end of parsing");
    }Many people use a boolean to save the where they are at (in the xml doc)
    But since your xml doc is simple, it's not necessary
    Also...If the content value is a long string..I would use a StringBuffer
    instead of String (because the SAX Parser can call on the character() method multiple time...Normally, it only call on it once. Using StringBuffer reduce Object creating and reduce garbage collection.

  • After downloading & installing application of adobe creative suite cs2 version 6,  screen of adobe photoshop cs2 is not opened by clicking icon . message is giving " ausba4.dll " was not present. Please guide me.?

    I have downloaded & installed adobe creative suit cs2 version 6 but when I click the icon of adobe photoshop in desktop it is not opened & giving message " this application has failed to start because " ausba4.dll " was not found. reinstalling of the application may fix the problem " I have reinstall & opened many times but even then it is not opened. Please guide me accordingly.

    I'd try disabling the Twain_32.8BA plugin in
    C:\Program Files\Adobe\Adobe Photoshop CS2\Plug-Ins\Import-Export
    You can disable the plugin by putting an ~ (tilde) in front of the name or moving the plugin to your desktop.
    Then try photoshop cs2 and see if you still get the error message.
    I suspect the error has to do with your scanner driver, since photoshop cs2 does not have an ausba4.dll

  • My mac has a virus yes I'm 100% sure it is one i get al kinds of pop ups only in safari though please guide me on how to reset it or where to go from here in detail new to macs

    My mac has a virus yes I'm 100% sure it is one i get all kinds of pop ups only in safari though please guide me on how to reset it or where to go from here in detail im new to macs

    Please post a screenshot that shows what you mean. Be careful not to include any private information.
    Start a reply to this message. Click the camera icon in the toolbar of the editing window and select the image file to upload it. You can also include text in the reply.

  • Please help me to find my iPad and iPhone 5C. I lost all of them last night. I set up icloud for my devices but i can't find them because they were not connect to the Internet. Please guide me other ways to find my "best friends".

    Dear Apple,
    Please help me to find my iPad Air 2 64 GB and iPhone 5C 8GB. They're in IOS 8.0 maybe...I lost all of them last night. I set up icloud for my devices but i can't find them because they were not connect to the Internet. Please guide me other ways to find my "best friends". They're very important to me. Many important files for my job in here and it has sentimental value to me. My boyfriend gave it for me so i don't want to lose them. And because i just lost my iPad Air last 3 month, and now i just bought iPad Air 2 two months ago. I'm so sad and lost. I want to catch the thief to the police so bad because they keep my bag and many other important things. I can not do anything without them. Please help me and contact me via my email or my phone. Thank you very much. Hope to receive your answer soon.

    Hey there thaovy309,
    Welcome to Apple Support Communities.
    The linked article below provides a lot of great information and suggestions that should address your concerns about your data and finding your lost or stolen iPhone 5c and iPad Air 2.
    If your iPhone, iPad, or iPod touch is lost or stolen - Apple Support
    Take care,
    -Jason

  • Please guide me how to delete the OLD claimed trip details

    Hi SAP Gurus
    We have corrected the all the cliams by newly created an posted properly today , how ever they are struck now and since they are form old employees (2007-2008) , few are still active / terminated/ retiree staus cant delete them nor make it zero. But appear in our report as pending...
    Please guide me how to delete the old trips.. your support really appreciated..
    Thanks
    Shan

    Hi Shan,
    As per my knowledge, no table should be deleted. Check the below link for more info.
    http://help.sap.com/saphelp_erp60_sp/helpdata/en/73/6bf037f1d6b302e10000009b38f889/frameset.htm
    <<removed>>
    Thanks,
    Praisty
    Edited by: Matt on Jul 26, 2011 3:11 PM

  • Link is not working for one role. how to check please guide.

    Hi Expert,
    I have a simple question but as don;t aware of some of the techincal area not able to understand where to check.
    I have a link under document flow in offer( opportunity) where for one role sales support user the link is not happening. I have checked for other role its working fine.I understand that for this role the link  will not work as per the role maintianed.
    But where this link got maintained and how i will be able to check which link is tagged to which profile.
    rolewise mappeing with link.
    Please guide.
    Prem.

    Hello Prem,
    Please check the navigation bar profile from your business role.
    Then go to the navigation bar profile settings, you can find the details settings there.
    If it is a link under some work center, you need to start from the work center.
    If it is a direct link, then start from the derect link group.
    Hope this could be helpful.
    Best regards,
    'Maggie

  • HT4718 i got mountain lion as an upgrade to my new macbook pro i want to reinstall it please guide me how to reinstall

    i want to reinstall moutain lion please guide me how to do it

    Welcome to Apple Support Communities
    Press Command and R keys when your Mac starts and reinstall OS X

  • HT3777 I have a Window 7 HP laptop. I want to install Snow Leopard on an external hard drive as the memory space on my laptop is very less. I have the original snow leopard disc and I think it's a retail version . Please guide me through the installation.

    I have a Window 7 HP laptop. I want to install Snow Leopard on an external hard drive as the memory space on my laptop is very less. I have the original snow leopard disc and I think it's a retail version . Please guide me through the installation in details. Can you also please let me know about this boot camp.

    You cannot. From a legal standpoint, the license agreement for OS X mandates that you run OS X only on Apple hardware. HP is not (yet) owned by Apple.
    From a technical standpoint, your HP laptop doesn't use EFI, but rather an early predecessor called a BIOS. Apple is the only vendor of consumer computer hardware that uses EFI; other vendors reserve EFI for use in servers.
    Secondly, Apple's operating systems support a rather limited number of configurations of video hardware and mainboard chipsets directly since they need only support those systems that they manufacture. You cannot use Windows software or drivers on OS X, so prior to installation, you would need to write your own hardware drivers for your laptop, create an OS X drive image on a Mac, and then modify that image with your drivers before putting it in the HP.
    It will be simpler (and legal), to simply purchase a used Mac. Apple's online store has refurbished MacBook Airs starting at $850 and Mac Minis for $700. If you go to e-bay or craigslist, you'll find used Macs for considerably less.

  • I have an iMac with mountain lion 10.8.3 with boot camp 5.0.2 .i installed windows 7 -64 bit with boot camp but the boot camp didn't install drivers for windows please guide me for trouble shooting .

    i have an iMac with mountain lion 10.8.3 with boot camp 5.0.2 .i installed windows 7 -64 bit with boot camp but the boot camp didn't install drivers for windows please guide me for trouble shooting .

    Kappy wrote:
    Boot Camp doesn't install the drivers. You have the drivers on a separate USB device if you followed directions. Once in Windows connect the USB drive with the driver software. It should startup automatically and install the drivers.
    You don't even need to do that. As downloading the drivers from within Boot Camp Assistant can be unreliable, it is better to get the package directly from here:
    http://support.apple.com/kb/DL1638
    Copy the .zip file to a USB flash drive or burn it to a DVD in OS X. Install Windows as normal, insert the flash drive/DVD in Windows, copy the .zip file to the hard drive, extract it, then run the setup executable.

  • HT2305 I have forget my 4 digit passcode for my ipad 3 and exhausted all the attempts, Now the screen shows "ipad is disabled connect to itunes" How can I unlock my ipad now. Also I have not put "Find my iphone" in icloud as well. Please guide me to unloc

    I have forget my 4 digit passcode for my ipad 3 and exhausted all the attempts, Now the screen shows "ipad is disabled connect to itunes" How can I unlock my ipad now. Also I have not put "Find my iphone" in icloud as well. Please guide me to unlock it.

    Also when I am trying to connect ipad to my windows PC, it shows, your software is up to date and later starts restoring while updating again. Then automatically it stops to update halfway and I have to repeat the process again and again, still in vain.

Maybe you are looking for

  • Hard drive problem

    Hi all Last month my 2012 macbook pro hard drive failed. I replaced it with a western digital hard drive and updated to installed Mavericks. I've hardly used or moved my Macbook in weeks since and today the grey loading bar appeared and disk utility

  • How to include JavaScript in a list instance's form in Visual Studio

    So I know you can use JSLink to include JavaScript files in list definitions in Schema.<g class="gr_ gr_8 gr-alert gr_spell ContextualSpelling ins-del multiReplace" data-gr-id="8" id="8">xml</g> like so: <Form Type="DisplayForm" Url="DispForm.aspx" S

  • How to start over in lightroom?

    I really have never learned how to maximize this program and normally use Adobe Bridge and Photoshop for my workflow.  I have imported over 100,000 photos in lightroom over time.  I would like to know how to wipe the slate clean so I can start over. 

  • Problem with writing into txt file on the Web

    Hello friends - please could you give me an advice? Java console says: Exception in thread "AWT-EventQueue-2" java.security.AccessControlException: access denied (java.io.FilePermission http:\web.telecom.cz\jiriczech\xanado.txt write) Thank you a lot

  • Example file, illustrator file with variables linked to xml

    CS5 – Where can i find an example of an illustrator files with variables, linked to an xml file. We want to export it immediately to .pdf format when the file is linked. Is this possible? The illustrator help files are not so clear about this matter.