Parsing a xml file

i need a code for this...
write a class for "myxmlparser" to parse "*.xml" fileto "*.dtd" file.
sundar

You do not parse a XML file into a DTD. The DTD is a tool you may use to constrain the contents of the XML document. In short, the DTD allows you to define whether a given XML document is valid, apart from simply being well-formed.
You parse XML either in one of three ways:
SAX: respond to XML parsing events in your Java app.
DOM: build an in-memory tree of XML data
Custom: anything goesIf your task is to take an arbitrary XML document and generate an associated DTD (thought this would not be a standard methodology), you would have to write this code yourself and familiarize yourself with both XML and DTD's.
- Saish
"My karma ran over your dogma." - Anon

Similar Messages

  • Can someone help me with a problem of parsing an XML file?

    Hello,
    I'm having some problems parsing an xml file. I get a SAXNotSupportedException when setting a property value.
    Here is the piece of code where I have the problem:
    SAXParserFactory spf = SAXParserFactory.newInstance();
    spf.setNamespaceAware(true);
    SAXParser saxParser = spf.newSAXParser();
    XMLReader xmlReader = saxParser.getXMLReader();
    DefaultHandler defHandler = new DefaultHandler();
    xmlReader.setProperty("http://xml.org/sax/properties/lexical-handler", defHandler);
    and the log is:
    Problem with the parser org.xml.sax.SAXNotSupportedException: PAR012 For propertyID "http://xml.org/sax/properties/lexical-handler", the value "org.xml.sax.helpers.DefaultHandler@4ff4f74a" cannot be cast to LexicalHandler.
    http://xml.org/sax/properties/lexical-handler org.xml.sax.helpers.DefaultHandler@4ff4f74a LexicalHandler
    I've been working on this problem but I can't find the error.
    Does anyone have an idea of what to do to solve it?
    Thanx in advance,
    M@G

    before deciding which XML technology to use, you should see if your application fit in the category below:
    use SAX:
    1. The XML file is rather large (30 or 40+ MB)
    2. I don't need the xml document in memory. I will parse the document and store the data in my own object.
    use DOM or JDOM
    1. The XML file is relatively small (less than 30 MB) or I can increase the runtime memory for larger xml file.
    2. I will need to walk up and down the xml document tree severals time.
    3. My application is in Java and it's not going to be rewritten in C++, etc (use JDOM)
    NOTE:
    JDOM is rather easier to use (for Java developer), but it's not an www.org.com standardlized xml parser.
    personally, i like JDOM for traversing the DOM.

  • Parsing of xml file in oracle stored procedure on linux server

    We have an XML file in the "/database/stats/dev/xml1/" path and tried to parse the file using the below code :
    p := xmlparser.newParser;
    xmlparser.setValidationMode(p, FALSE);
    -- xmlparser.setErrorLog(p, errfile);
    xmlparser.setBaseDir(p, dir);
    xmlparser.parse(p, inpfile);
    doc := xmlparser.getDocument(p);
    xmlparser.freeParser(p);
    The above procedure is throwing below mentioned exception at "xmlparser.parse(p, inpfile);".
    SQLCODE: ORA-31001
    SQLERRM: ORA-31001: Invalid resource handle or path name "/xml1.dtd"
    The xml file contains the following line, which is giving an error, while parsing the xml file.
    <!DOCTYPE CCIOrder SYSTEM "xml1.dtd">
    Directory Structure:
    OWNER DIRECTORY_NAME DIRECTORY_PATH
    SYS XML1 /database/stats/dev/xml1

    you'll need to use server-side code to check the xml file names in that folder, return that list to flash and display the list to the user.
    or, if you can get by presenting a hard-coded list of xml files, you won't need any server-side coding.

  • How to Parse an XML file using SAXParser in java.

    Hi all
    Am a bit new to XML files and have no idea about SAXParsers ... Now my problem is to parse this XML file below
    <?xml version="1.0" encoding="UTF-8"?>
    <sc:memory_segmentation xmlns:sc="sc_memory_segmentation.xsd">
       <sc:architecture name="MPC55xx"></sc:architecture>
       <sc:derivative name=""></sc:derivative>
       <sc:configuration name=""></sc:configuration>
       <sc:memory name="Internal ROM" type="ROM">
          <sc:area-list>
             <sc:area name="Bootmanager" type="BOOTMANAGER">
                 <sc:segment-list>
                   <sc:segment name="ROM page 1">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                 </sc:segment-list>
             </sc:area>
             <sc:area name="Bootloader SWE" type="BOOTLOADER">
                 <sc:segment-list>
                   <sc:segment name="ROM page 2">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                   <sc:segment name="ROM page 3">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                </sc:segment-list>
             </sc:area>
             <sc:area name="Application SWE 1" type="APPLICATION">
                <sc:segment-list>
                   <sc:segment name="ROM page 4">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                   <sc:segment name="ROM page 5">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                   <sc:segment name="ROM page 6">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                   <sc:segment name="ROM page 7">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                </sc:segment-list>
             </sc:area>
             <sc:area name="Application SWE 2" type="APPLICATION">
                <sc:segment-list>
                   <sc:segment name="ROM page 8">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                </sc:segment-list>
             </sc:area>
             <sc:area name="Application SWE 3" type="APPLICATION">
                <sc:segment-list>
                   <sc:segment name="ROM page 9">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                </sc:segment-list>
             </sc:area>
             <sc:area name="Application SWE 4" type="APPLICATION">
                <sc:segment-list>
                   <sc:segment name="ROM page 10">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                </sc:segment-list>
             </sc:area>
          </sc:area-list>
       </sc:memory>
       <sc:memory name="Internal RAM" type="RAM">
          <sc:area-list>
             <sc:area name="RAM" type="RAM">
                <sc:segment-list>
                   <sc:segment name="RAM page 1">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                   <sc:segment name="RAM page 2">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                   <sc:segment name="RAM page 3">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                   <sc:segment name="RAM page 4">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                   <sc:segment name="RAM page 5">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                </sc:segment-list>
             </sc:area>
          </sc:area-list>
       </sc:memory>
       <sc:memory name="Internal EEPROM" type="EEPROM">
          <sc:area-list>
             <sc:area name="EEPROM" type="EEPROM">
                <sc:segment-list>
                   <sc:segment name="EEPROM page 1">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                   <sc:segment name="EEPROM page 2">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                   <sc:segment name="EEPROM page 3">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                   <sc:segment name="EEPROM page 4">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                   <sc:segment name="EEPROM page 5">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                </sc:segment-list>
             </sc:area>
          </sc:area-list>
       </sc:memory>
    </sc:memory_segmentation> And from this file I need to make 3 Hashtables out of it one for ROM , RAM and EEPROM containg Segment information i.e. Segment start and end addresses and Area type of the segment....
    If anyone could at least guide me with the basic commands and structure of the parser it would be really really great ...
    Thanks a lot
    Anisha

    Normally if you have no idea about X, the first thing you should do is google "X tutorial". You will find plenty of them out there. And the advantage is, they are better written than whatever we spend two minutes throwing together here. Not to mention that it saves us the two minutes.
    But if you have specific questions with your SAX parser when you get it going, then ask them here. Actually, ask them in the XML forum here, not this one.

  • Parsing an XML file

    I've written a program which is partly responsible for parsing an XML file that can be found on the web. I appear to be accessing the XML file correctly, but when I try to parse it I am running into a problem. I try to create a List object that contains all of the children of the root element. The code looks like this:
    Document doc = parser.build(xmlFile);
    Element root = doc.getRootElement();
    List rootChildren = root.getChildren();But I get an error that say that "the type List is ambiguous". I am importing java.util.*. I am trying to do this exactly like a few examples I found on the web, but I can't seem to get past this issue. What do I need to keep Eclipse from telling me that List is not an ambiguous type.

    Maybe you haveimport java.util.*;
    import java.awt.*;Both packages contains a List class.
    In that case, the compiler doesn't know which one you're talking about.
    If you don't need the java.awt.List class here, try not to import it.
    If you need it, use the fully qualified class name in your code.

  • Parse exisitng xml file and recreate another xml file with different struct

    Is it possible in java using dom parser to parse an exisiting xml file and recreate a new xml file from data obtained by parsing old xml file.
    I checked on old forum threads and everywhere either parsing xml file has been explained or creating new xml file from scratch has been shown.
    Any examples/guidance will be appreciated....

    The general process is:
    Document dom1 = ... // the parsed document
    Document dom2 = ... // new document constructed on the fly
    Node nD1 = ... // some random node found in dom1
    // copy the node from dom1 and associate with dom2
    Node nD2 = dom2.importNode(nD1, true);
    // ... treat nD2 as a node which can now be inserted into dom2 ...
    Node otherD2 =  ... // some other node already in dom2
    otherD2.appendChild(nD2);Note, in this example the nD1 node is copied (including any sub-nodes) into a new node, nD2. You can alternately move the node from one Document to another using Document.adoptNode(), however this may fail (see the javadoc).

  • Parsing a XML file using Jdom-Problem.

    Hi all,
    I am reposting it as I was told to format the code and send it again.
    I am trying to parse a xml file using a jdom java code.This code works fine if I remove xmlns attribute in the root element. (I get the expected result) .If the "xmlns" attribute is put in the xml as it should be then the parsing and retrieving returns null. Please tell me how to fix this issue.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Xml
    <process name="CreateKBEntryService" targetNamespace="http://serena.com/CreateKBEntryService" suppressJoinFailure="yes" xmlns:tns="http://serena.com/CreateKBEntryService" xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/" xmlns:bpelx="http://schemas.oracle.com/bpel/extension" xmlns:ora="http://schemas.oracle.com/xpath/extension" xmlns:nsxml0="http://localhost:8080/axis/services/CreateKBEntryService" xmlns:nsxml1="http://DefaultNamespace" xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/">
    <partnerLinks>
    <partnerLink name="client" partnerLinkType="tns:CreateKBEntryService" myRole="CreateKBEntryServiceProvider"/>
    <partnerLink name="CreateKBEntryPartnerLink" partnerLinkType="nsxml0:CreateKBEntryLink" partnerRole="CreateKBEntryProvider"/>
    </partnerLinks>
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
    Java:
    import java.io.*;
    import java.util.*;
    import org.jdom.Document;
    import org.jdom.Element;
    import org.jdom.input.SAXBuilder;
    public class sample1 {
    public static void main(String[] args) throws Exception {
    // create a XML parser and read the XML file
    SAXBuilder oBuilder = new SAXBuilder();
    Document oDoc = oBuilder.build(new File("**xml file location**"));
    Element root = oDoc.getRootElement();
    System.out.println(root.getName());
    String tgtns= root.getAttributeValue("targetNamespace");
    System.out.println("tgt ns "+ tgtns);
    List list= root.getChildren("partnerLinks");
    Iterator it1= list.iterator();
    System.out.println("Iterator 1 - "+list.size());
    while(it1.hasNext()){
    Element partnerlinks = (Element)it1.next();
    List list2= partnerlinks.getChildren("partnerLink");
    System.out.println("iterator 2 - "+list2.size());
    }~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Result:
    Without Xmlns in xml file(Expected and correct output)
    process
    tgt ns http://serena.com/CreateKBEntryService
    Iterator 1 - 1//expected and correct result that comes when I remove xmlns attribute from xml
    iterator 2 - 2
    Result with xmlns:
    process
    tgt ns http://serena.com/CreateKBEntryService
    Iterator 1 - 0 //instead of 0 should return 1

    LOL
    This is what you get for working 12 hours straight....
    I changed:
    xmlObject["mydoc"]["modelglue"]["event-handlers"]["event-handler"][i].xmlAttrib utes["name"]<br>
    to:
    #mydoc["modelglue"]["event-handlers"]["event-handler"][i].xmlAttrib utes["name"]#<br>
    xmlObject is the name of my xml object in memory, and then you reference from the root of the xml doc down the chain.
    Sorry for the inconvenience,
    Rich

  • How to parse a XML file

    I am a new learner to XML & JAVA,I dont't know how to parse the XML file using JAXP,Who can tell me,Who can write an Example?
    thx
    Best Regards.

    Using the SAXParser in JAXP the parsing of the XML file is event driven.
    Instantiate the parser:
    SAXParserFactory factory = SAXParserFactory.newInstance();
    SAXParser parser = factory.newSAXParser();
    InputSource is = new InputSource(new FileReader(theXML));call the parse method:
    parser.parse(is, this);The following events are fired as the parser works through the XML public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws org.xml.sax.SAXException
    public void endElement(String namespaceURI, String localName, String qName) throws org.xml.sax.SAXException
    characters(char[] ch, int start, int length)etc.
    You write what you want within each of these sections to handle the structure of your data. Keep in mind SAX is useful only when you know the structure of your XML.

  • Can Document Builder parse an XML file from a URL?

    Warning: Java newbie here...
    My problem is that I am able to parse an XML file if it is copied into my project, but not if it is a full URL. Here is what I got so far, that works.
    import java.io.*;
    import java.net.*;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    try {
        File file = new File("path/to/file.xml");
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        Document doc = db.parse(file);
        doc.getDocumentElement().normalize();
        NodeList nodeLst = doc.getElementsByTagName("Names");
        for (int s = 0; s < nodeLst.getLength(); s++) {
            Node parentNode = nodeLst.item(s);
            if (parentNode.getNodeType() == Node.ELEMENT_NODE) {
                Element parentElmnt = (Element) parentNode;
                NodeList nameElmntLst = parentElmnt.getElementsByTagName("Name");
                //etc.
    } catch (Exception e){
        e.printStackTrace();
    }So building off of this I have tried to parse an input stream like this:
    URL url = new URL("http://example.com/file.xml");
    InputStream is = url.getInputStream();
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    Document doc = db.parse(is);which gives me the following error
    [Fatal Error] :-1:-1: Premature end of file.
    LOG: HME receiver connected
    org.xml.sax.SAXParseException: Premature end of file.
    I also even tried to write the file locally like this:
    URL url = new URL("http://example.com/file.xml");
    HttpURLConnection urlcon = (HttpURLConnection) url.openConnection();
    urlcon.connect();
    InputStream is = urlcon.getInputStream();
    File file = new File("path/to/file.xml");
    OutputStream out = new FileOutputStream(file);
    byte buf[] = new byte[1024];
    int len;
    while((len=is.read(buf))>0)
        out.write(buf,0,len);
    out.close();
    is.close();
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    Document doc = db.parse(file);This gives the same error.
    If anyone can point me in the right direction I would forever thankful. I've tried search Google and the Sun forums, but haven't quite found the solution. I think it is because I need to try something else completely. Thank you for reading.
    ~~~~ Jeremy

    jmose wrote:
    If I copy the page, it works as shown in the first code block. In the third codeblock the file is never even created, so I cannot tell if that works or not.So: having the parser access the URL fails, and having some other Java code access the URL also fails in the identical way? That suggests the problem is simply accessing the URL via Java code. Presumably when you downloaded the data from the URL, you used a browser to do it and not wget or something like that?

  • Error "Cannot parse appinfo xml file."

    Periodically my users are getting the error below when trying to launch BPC for Excel:
    "Cannot parse appinfo xml file."
    Seems this file is getting corrupted somehow. If I remove the file from their citrix profile and they relogin, the file is recreated and then they can launch BPC for Excel. Until then though, they get this error and sometimes it says the Web App server is unavailable, when it indeed is available.
    Anyone experience this, or have any ideas as to the problem?
    Thanks,
    Greg

    Please notice that inquiries related to BPC topics should now be posted to dedicated forums.
    Business Planning and Consolidations, version for SAP NetWeaver
    <a class="jive_macro jive_macro_community" href="" __jive_macro_name="community" modifiedtitle="true" __default_attr="2065"></a>
    Business Planning and Consolidations, version for the Microsoft Platform
    <a class="jive_macro jive_macro_community" href="" __jive_macro_name="community" modifiedtitle="true" __default_attr="2066"></a>
    Please adjust any bookmarks or shortcuts you may have set previously to point to this forum.
    Best regards,
    [Jeffrey Holdeman|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/profile/jeffrey+holdeman]
    SAP BusinessObjects
    Enterprise Performance Management
    Regional Implementation Group

  • How quickly parse big XML file (60 MB) ???

    How quickly parse big XML file (60 MB) ???

    I assume you mean load it into XML DB ?. Fundamentally your document is about the upper limit for 9.2.x. I would strongly recommend trying to break it up into a set of smaller documents using a SAX parser before trying to load it into XML DB. In 10g it should be possible to load much bigger documents than this.

  • Want parse huge xml file for CDATA

    HI all
    I want to parse hude xml file for getting values of CDATA
    can u plz give me sample code for that
    here i am attaching the part of my xml file
    <initParams>
    <param description="simulation mode " name="smtpSimulationMode" passOn="false" required="false" type="bool" varSubstitute="false">
    <![CDATA[false]]>
    </param>
    <param description="full name of smtp host" name="smtpHost" passOn="false" required="true" type="string" varSubstitute="false">
    <![CDATA[222222]]>
    </param>
    <param description="smtpUserName for authentication" name="smtpUserName" passOn="false" required="false" type="string" varSubstitute="false"/>
    <param description="smtpUserPassword for authentication" name="smtpUserPassword" passOn="false" required="false" type="string" varSubstitute="false"/>
    <param description="ip address for remote server" name="serverId" passOn="false" required="true" type="string" varSubstitute="false">
    <![CDATA[1111111]]>
    </param>
    <param description="location of file on remote server side" name="fileRemoteLocation" passOn="false" required="false" type="string" varSubstitute="false">
    <![CDATA[test/]]>
    </param>
    <param description="user name for authentication" name="userName" passOn="false" required="true" type="string" varSubstitute="false">
    <![CDATA[abc]]>
    </param>
    </initParams>
    thanks in advance

    There are several Java XML API's available. SAX, JXpath, DOM4J, Xerces, etcetera.

  • Opatch error 'Unable to parse the xml file'

    Hi there,
    I am new to installing patches on Oarcle and I need to install patch 12375678 on my windows system, Oracle 11.2.0.2.
    I have followed the instructions in the readme.txt file, but got this error and I have not come across anywhere on the web that explain how I could fix it.
    Could you please advise?
    Thanks
    C:\>set oracle_home=C:\oracle\product\11.2.0\dbhome_1
    C:\>echo %oracle_home%
    C:\oracle\product\11.2.0\dbhome_1
    C:\>cd C:\oracle\product\11.2.0\dbhome_1\inventory\oneoffs\12375678
    C:\oracle\product\11.2.0\dbhome_1\inventory\oneoffs\12375678>opatch apply
    Invoking OPatch 11.2.0.1.1
    Oracle Interim Patch Installer version 11.2.0.1.1
    Copyright (c) 2009, Oracle Corporation. All rights reserved.
    Oracle Home : C:\oracle\product\11.2.0\dbhome_1
    Central Inventory : C:\Program Files\Oracle\Inventory
    from : n/a
    OPatch version : 11.2.0.1.1
    OUI version : 11.2.0.2.0
    OUI location : C:\oracle\product\11.2.0\dbhome_1\oui
    Log file location : C:\oracle\product\11.2.0\dbhome_1\cfgtoollogs\opatch\opatch2
    012-05-21_15-28-52PM.log
    Patch history file: C:\oracle\product\11.2.0\dbhome_1\cfgtoollogs\opatch\opatch_
    history.txt
    ApplySession applying interim patch '12375678' to OH 'C:\oracle\product\11.2.0\d
    bhome_1'
    Running prerequisite checks...
    OPatch detected non-cluster Oracle Home from the inventory and will patch the lo
    cal system only.
    Backing up files and inventory (not for auto-rollback) for the Oracle Home
    Backing up files affected by the patch '12375678' for restore. This might take a
    while...
    Backing up files affected by the patch '12375678' for rollback. This might take
    a while...
    Patching component oracle.rdbms, 11.2.0.2.0...
    Copying file to "C:\oracle\product\11.2.0\dbhome_1\rdbms\xml\xsl\kuexttbl.xsl"
    Patching component oracle.rdbms.dbscripts, 11.2.0.2.0...
    Copying file to "C:\oracle\product\11.2.0\dbhome_1\rdbms\admin\prvtbpd.plb"
    Copying file to "C:\oracle\product\11.2.0\dbhome_1\rdbms\admin\prvtbpw.plb"
    ApplySession adding interim patch '12375678' to inventory
    Interim Patch metadata parsing failure... 'Unable to parse the xml file.'
    ApplySession failed: ApplySession failed in system modification phase... 'Unable
    to create patchObject'
    OPatch will attempt to restore the system...
    Restoring the Oracle Home...
    OPatch was able to restore your system. Look at log file and timestamp of each f
    ile to make sure your system is in the state prior to applying the patch.
    OPatch failed with error code = 73

    your actions.xml must not be able to be read.
    open it in notepad yourself to see does it open, if so its not corrupt, if doesnt open download patch again.
    More then likely will be fine so try locate the patch in a shorter home path, like c:\patches\12375678 and see does it install from there.
    Only other thing I can think of is the main inventory.xml, usually c:\program files\oracle\inventory\inventory.xml
    try notepad with that too.

  • How to parse large xml file

    I need to parse large xml file which contains following tag. The size of the file is upto 10MB-50MB or more.
    <departments>
    <department>
    <a_depart id="124">
    <b_depart id="Bss_253">
    <bss_depart id="253">
    <attributes>
    <name_one>abc</name_one>
    </attributes>
    </bss_depart id="253">
    </b_depart id="Bss_253">
    </a_depart id="124">
    </department>
    <department>
    <a_depart id="124">
    <b_depart id="Bss_254">
    <mss_depart id="253">
              <attributes>
              <name_one>abc</name_one>
              <name_two>xyz</name_one>
              </attributes>
         </mss_depart>
         </b_depart>
    </a_depart>
    </department>
    <department>
    <a_depart id="124">
    <b_depart id="Bss_254">
    <mss_depart id="255">
              <attributes>
              <name_one>abc</name_one>
              <name_two>xyz</name_one>
              </attributes>
         </mss_depart>
         </b_depart>
    </a_depart>
    </department>
    <department>
    <a_depart id="125">
    <b_depart id="Bss_254">
    <mss_depart id="253">
              <attributes>
              <name_one>abc</name_one>
              <name_two>xyz</name_one>
              </attributes>
         </mss_depart>
         </b_depart>
    </a_depart>
    </department>
    I want to get the infomation for that xml file. like mss_depart id=233, building xpath dyanmically for every id and loading
    that using dom4j. which is very very slow.
    Is there any other solution for that to read the data using sax parser only.
    I want to execute the xpath or data for the following way.
    //a_depart/@id ------> all the ids of a_depart tags if it returns 3 values say 123,124,125
    after that i want to execute
    //a_depart[@id='123']/b_depart/@id like this ...to retrive the values of all the levels ...
         I am executing following xpath for every unique ids at all levels.
         List l = doc.selectNodes(xPathForID);
         List l1 = doc.selectNodes(xPathForAttributes+attributes.get(j)+"/text()");
    But it is very slow and taking lot of time.
    Is there any other way to solve this problem. If any please mail me it is urgent.
    I am using jdk1.4 and jdk1.5
    Is there any support for sax parser to execute xpath in jdk1.5 direclty, with out using dom4j
    Thanks in advance....

    I doubt you will find a preexisting solution to your problem.
    SAX is usually recommended for processing big files (where "big" is undefined"). It works on big files by avoiding the messy problem of storing the data -- that is left as an exercise to you.
    DOM (and its variants) works by building a Document object as the head of the tree of objects for the entire contents. With DOM, you can then use XPath, because there is something to search that is already in memory. To use XPath, you seem to have two choices, build a DOM-ish tree, or if you can find an XPath processor (I'm not sure if one exists) that can process the XML file directly, but it will be slow, since you are looking for "all" occurences of an attribute, and this means you have to read the entire file each time.
    It might be worth exploring a hybrid approach -- use SAX to get some information, and build your own objects to store the data. Maybe a HashMap as the main index. But, that will keep you from using XPath, since you do not have the data structures it expects.
    A third alternative would be to look at JAXB. It builds Java code from a Schema of your data and then when you import the data, it creates the necessary objects and fills in values. But, I don't think XPath woll work there either.
    Dave Patterson

  • How different Web Services can use a class which parses an XML file

    I am using RAD6.1 for developing and deploying web services.As I am using 15 web Services which uses a common class which is used to parse an XML file.As this XML file should be parsed only once and should be used by all the web services.I have made this common class as Singleton but it works as singleton for only one webservice and for other web service again it is parsing the xml file.I want to parse this xml file only once and used by all the web services.In my case tis file is parsed 15 times for 15 web services, but it should be parse donly once and used by all 15 services.Please give me the solution.
    Thanks and Regards
    Sayeeduzzaman

    Hello,
    the 15 Webservices should have a static attribute which contains the xml:
    private static String xml;
    then initialise the xml like this:
    if (xml == null)
    xml = parseIt();
    else
    //do nothing, XML already initialised!
    }

Maybe you are looking for

  • Please help - need to import/create song snippets in iMovie

    Hi - I'm making a movie in '06 HD which requires a series of short (apx. 1 minute each) song segments taken from longer songs (apx 4 minutes each). After learning how to first crop the song in iTunes, I could not figure out how to import just the cro

  • How to create a condition based on a select that retrieve dynamically a LOV

    Hi all, I need to create a condition based on a select that retrieve dynamically a LOV. So, the condition have to be: inventory_item_id NOT IN (SELECT inventory_item_id FROM apps.mtl_system_items_kfv WHERE concatenated_segments = 'GENERAL_FAULTS_IPTV

  • Error 513 in Satellite System Service Desk

    Hello Experts, I have a big problem in my satellite system, when I try to create a support message. Till I began to configure the change management it works fine. I don't know what happend. Here are some screenshots of the configuration. This is the

  • Can the old product be catched if I change the product in an ite?

    Hi experts, Is there anybody knows how can I catch the old product if I change the product in an item when placing orders? I mean just change the product number,not deleting the whole line. Do you know the badi/function name?? Jerry. Thanks in advanc

  • Import PDF?

    I have a 70-page PDF file that I need to insert into another PDF file that I am creating in Pages. Is there a way to somehow import that into Pages? When I tried just a regular Insert, it only pulled in the first page.