Help parsing XML file

Hi All,
I have some troubles trying to load and parse a simple xml file like this:
<?xml version="1.0" encoding="UTF-8"?>
<entry>
     <id>1</id>
</entry>
<entry>
     <id>2</id>
</entry>
With this few lines of code:
            var url:URLRequest = new URLRequest("myXML.xml");
            var xml:XML;
            var rss:URLLoader = new URLLoader();
            rss.load(url);
            rss.addEventListener(Event.COMPLETE, readRss);
            function readRss(e:Event):void{
                xml = XML(rss.data);               
                var ns:Namespace=xml.namespace();
                txt_field.text=xml..ns::entry[0].ns::id;           
I get this error: A conflict exists with inherited definition spark.components:Application.url in namespace public.
in: var url:URLRequest = new URLRequest("myXML.xml");
Please help me ...  thank you in advance.
Michele

Hi Michele,
Try to use different name for your URLRequest object...It seems that there is conflict existing with the inherited url property of the Application and the one you declared so do the following..
var _url:URLRequest = new URLRequest("myXML.xml");
var xml:XML;
var rss:URLLoader = new URLLoader();
rss.load(_url);
Thanks,
Bhasker

Similar Messages

  • How to compare after parsing xml file

    Hi,
    following code, parse the input.xml file, counts how many nodes are there and writes the node name and its value on screen.
    1) i am having trouble writing only node name into another file instead of writing to screen.
    2) after parsing, i like to compare each node name with another .xsd file for existence.
    Please keep in mind that, input.xml is based on some other .xsd and after parsing i have comparing its tag with another .xsd
    Need you help guys.
    thanks
    * CompareTags.java
    import java.io.*;
    import org.w3c.dom.*;
    import org.xml.sax.*;
    import javax.xml.parsers.*;
    import javax.xml.transform.*;
    import javax.xml.transform.dom.*;
    import javax.xml.transform.stream.*;
    /** This class represents short example how to parse XML file,
    * get XML nodes values and its values.<br><br>
    * It implements method to save XML document to XML file too
    public class CompareTags {
    private final static String xmlFileName = "C:/input.xml";
         int totalelements = 0;
    /** Creates a new instance of ParseXMLFile */
    public CompareTags() {
    // parse XML file -> XML document will be build
    Document doc = parseFile(xmlFileName);
    // get root node of xml tree structure
    Node root = doc.getDocumentElement();
    // write node and its child nodes into System.out
    System.out.println("Statemend of XML document...");
    writeDocumentToOutput(root,0);
                   System.out.println("totalelements in xyz tag " + totalelements);
              System.out.println("... end of statement");
    /** Returns element value
    * @param elem element (it is XML tag)
    * @return Element value otherwise empty String
    public final static String getElementValue( Node elem ) {
    Node kid;
    if( elem != null){
    if (elem.hasChildNodes()){
    for( kid = elem.getFirstChild(); kid != null; kid = kid.getNextSibling() ){
    if( kid.getNodeType() == Node.TEXT_NODE ){
    return kid.getNodeValue();
    return "";
    private String getIndentSpaces(int indent) {
    StringBuffer buffer = new StringBuffer();
    for (int i = 0; i < indent; i++) {
    buffer.append(" ");
    return buffer.toString();
    /** Writes node and all child nodes into System.out
    * @param node XML node from from XML tree wrom which will output statement start
    * @param indent number of spaces used to indent output
    public void writeDocumentToOutput(Node node,int indent) {
    // get element name
    String nodeName = node.getNodeName();
    // get element value
    String nodeValue = getElementValue(node);
    // get attributes of element
    NamedNodeMap attributes = node.getAttributes();
    System.out.println(getIndentSpaces(indent) + "NodeName: " + nodeName + ", NodeValue: " + nodeValue);
    for (int i = 0; i < attributes.getLength(); i++) {
    Node attribute = attributes.item(i);
    System.out.println(getIndentSpaces(indent + 2) + "AttributeName: " + attribute.getNodeName() + ", attributeValue: " + attribute.getNodeValue());
    // write all child nodes recursively
    NodeList children = node.getChildNodes();
              //int totalelements = 0;
    for (int i = 0; i < children.getLength(); i++) {
    Node child = children.item(i);
                   //     System.out.println("child value.."+child);
    if (child.getNodeType() == Node.ELEMENT_NODE) {
    writeDocumentToOutput(child,indent + 2);
                             if(node.getNodeName() == "DATA"){
                             totalelements = totalelements+1;}
                        //System.out.println("totalelements in DATA tag " + totalelements);
    /** Parses XML file and returns XML document.
    * @param fileName XML file to parse
    * @return XML document or <B>null</B> if error occured
    public Document parseFile(String fileName) {
    System.out.println("Parsing XML file... " + fileName);
    DocumentBuilder docBuilder;
    Document doc = null;
    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    docBuilderFactory.setIgnoringElementContentWhitespace(true);
    try {
    docBuilder = docBuilderFactory.newDocumentBuilder();
    catch (ParserConfigurationException e) {
    System.out.println("Wrong parser configuration: " + e.getMessage());
    return null;
    File sourceFile = new File(fileName);
    try {
    doc = docBuilder.parse(sourceFile);
    catch (SAXException e) {
    System.out.println("Wrong XML file structure: " + e.getMessage());
    return null;
    catch (IOException e) {
    System.out.println("Could not read source file: " + e.getMessage());
    System.out.println("XML file parsed");
    return doc;
    /** Starts XML parsing example
    * @param args the command line arguments
    public static void main(String[] args) {
    new CompareTags();
    }

    hi,
    check out the following links
    Check this blog to extract from XML:
    /people/kamaljeet.kharbanda/blog/2005/09/16/xi-bi-integration
    http://help.sap.com/saphelp_nw04/helpdata/en/fe/65d03b3f34d172e10000000a11402f/frameset.htm
    Check thi link for Extract from any DB:
    http://help.sap.com/saphelp_nw04s/helpdata/en/58/54f9c1562d104c9465dabd816f3f24/content.htm
    regards
    harikrishna N

  • How to parse xml file in midlet

    Hi Guys,
    i wish to parse xml file and display it in my midlet. i found api's supporting xml parsing in j2se ie., in java.net or j2se 5.0. Can u please help me what package to use in midlet?
    how to parse xml info and display in midlet? Plz reply soon......Thanks in advance....

    i have exactly the same problem with KXml2, but using a j2me-polish netbeans project.
    i've tried to work around with similar ways like you, but none of them worked. now i've spent 3 days for solving this problem, i'm a bit disappointed :( what is wrong with setting the downloaded kxml2 jar path in libraries&resources?
    screenshot

  • Parse XML files

    Hi
    Anyone know about support for parsing XML files in LabVIEW?
    (I mean specific XML support, I'm familiar with LabVIEWs file functions)
    regards
    Jan
    Sent via Deja.com http://www.deja.com/
    Before you buy.

    I assume you are referring to:
    http://www.savarese.org/oro/software/OROMatcher1.1.html
    Have you considered asking Savarese?
    Peace,
    Cameron Purdy
    Tangosol, Inc.
    http://www.tangosol.com
    +1.617.623.5782
    WebLogic Consulting Available
    "Laurent Mentek" <[email protected]> wrote in message
    news:[email protected]..
    Hi all,
    I'm started to develop with BEA WebLogic and I use ORACLE 8.1.6
    database.
    We need to map some XML tags as metadata in the database.
    Here is a concrete example with part of our XML files:
    XML files :
    <target>EDU</target>
    <question>
    <para>
    Please could you provide some references on nutritional status in
    the frail elderly?
    </para>
    </question>
    I use OROMatcher to parse xml files and it work fine.
    I can extract every element in line with success , but don't extract the
    value in <para> tag, for example.
    I don't no how to use the MULTILINE_MASK option and the ^ or $ to get
    this line.
    Anyone could give me an example of metadatas extaction using or no the
    MULTILINE_MASK option?
    Thanks a lot for your help.
    Laurent.

  • How to stop parse XML file

    When using saxParser.parse(XMLfile, handler) to parse XML file, How to stop the parsing but not exit. I catched thread interrupted in startElement(), but can not stop it because it still go through all other startElement()s and endElement()s. Is there any method or class can stop parse XML?
    Appreciate your help!
    Edward

    Please look at the technote:
    http://access1.sun.com/technotes/01185.html
    Hope this helps.
    Michelle Cope
    Sun Microsystems.

  • 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 parse XML files from normal FTP Servers?

    I want to parse xml files from a normal FTP Servers , NOT the sap application severs itself. How can i do that?
    I know how to use the SAPFTP getting and putting files ,but I don't want to download and then parse it.
    Who knows how to parse it directly? I Just need to read the contents into a database.
    Thanks.

    I want to parse xml files from a normal FTP Servers , NOT the sap application severs itself. How can i do that?
    I know how to use the SAPFTP getting and putting files ,but I don't want to download and then parse it.
    Who knows how to parse it directly? I Just need to read the contents into a database.
    Thanks.

  • Parsing XML Files to ABAP

    Hello All,
    There is a requirement for parsing of XML files to ABAP.
    1.How do we pick an XML file from Application server and also from FTP server?
    2.After picking the XML file how to parse that XML file to process it to create material master?

    Hi,
    Ur scenario is File to R/3
    For creating material master ..i guess there is IDoc named MATMAS.
    U can make use of it and execute File to IDoc Scenario.
    link for File to IDoc--
    https://www.sdn.sap.com/irj/scn/wiki?path=/display/xi/fileToIDOC&
    U need to pick XML file from FTP server...No need to parse XML file...just create data type which represents ur xml file structure and map it to IDoc fields.
    regards,
    Manisha

  • PARSING XML FILE;; PLS HELP ME

    Hello Every Body,
    Can someone help me , I try to parse an xml file using PL /SQL and i would like to get "acknowledged" , "state" and "COMPONENT id" from this xml file ;
    <?xml version="1.0" encoding="ISO-8859-1" ?> <COMPONENT_XML version="1.4" refresh="FIRST">
    - <COMPONENT_MAP>
    <COMPONENT id="0" version="1,0,3,2" acknowledged="YES" />
    - <COMPONENT id="4" version="1,0,4,3" acknowledged="YES">
    <ORDER id="2385" timeout="" state="IN_PROGRESS" history="P" acknowledged="NO" date_end="" time_begin="200703231741" />
    <ORDER id="4763" timeout="" state="IN_WAIT" history="Q" acknowledged="NO" date_end="" />
    </COMPONENT>
    <COMPONENT id="10" version="1,0,0,3" acknowledged="YES" />
    <COMPONENT id="11" version="1,0,0,2" acknowledged="YES" />
    <COMPONENT id="12" version="1,0,0,1" acknowledged="YES" />
    <COMPONENT id="13" version="1,0,0,1" acknowledged="YES" />
    <COMPONENT id="14" version="1,0,0,1" acknowledged="YES" />
    </COMPONENT_MAP>
    </COMPONENT_XML
    Can U help me please ?
    Thank you very much
    Best Regards,
    W

    Well , I feel That I 'm lonely here in this discussion, but I have tried and I have the solution ;
    SELECT EXTRACTVALUE (t1.COLUMN_VALUE, 'COMPONENT_XML/@version') version,
    EXTRACTVALUE (t1.COLUMN_VALUE, 'COMPONENT_XML/@refresh') refresh,
    ROW_NUMBER () OVER (PARTITION BY EXTRACTVALUE (t1.COLUMN_VALUE,
    'COMPONENT_XML/@version'
    ) ORDER BY NULL) rn,
    EXTRACTVALUE (t1.COLUMN_VALUE, 'COMPONENT/@id') ID,
    EXTRACTVALUE (t1.COLUMN_VALUE, 'COMPONENT/@version') ver,
    EXTRACTVALUE (t2.COLUMN_VALUE, 'COMPONENT/@acknowledged') acknowledged
    FROM TABLE
    (XMLSEQUENCE
    (EXTRACT
    (XMLTYPE
    ('<COMPONENT_XML version="1.4" refresh="FIRST">
    <COMPONENT_MAP>
    <COMPONENT id="0" version="1,0,3,2" acknowledged="YES" />
    <COMPONENT id="4" version="1,0,4,3" acknowledged="YES">
    <ORDER id="2385" timeout="" state="IN_PROGRESS" history="P" acknowledged="NO" date_end="" time_begin="200703231741" />
    <ORDER id="4763" timeout="" state="IN_WAIT" history="Q" acknowledged="NO" date_end="" />
    </COMPONENT>
    <COMPONENT id="10" version="1,0,0,3" acknowledged="YES" />
    <COMPONENT id="11" version="1,0,0,2" acknowledged="YES" />
    <COMPONENT id="12" version="1,0,0,1" acknowledged="YES" />
    <COMPONENT id="13" version="1,0,0,1" acknowledged="YES" />
    <COMPONENT id="14" version="1,0,0,1" acknowledged="YES" />
    </COMPONENT_MAP>
    </COMPONENT_XML>'
    '/COMPONENT_XML'
    ) t1,
    TABLE (XMLSEQUENCE (EXTRACT (t1.COLUMN_VALUE, '/COMPONENT_XML/COMPONENT_MAP/COMPONENT'))) t2

  • Need help on parsing xml file...

    Hi all,
    I need to collect some data from an Xml file using java. I have the following code with me but I am unable to get the required result. I am unable to get the data from the tags belonging to the header and footer elements. Please find the code and the sample xml file below.
    Program to parse XML:
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.List;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.NodeList;
    import org.xml.sax.SAXException;
    public class JobLogDetails3{
         //No generics
         List myJobs;
         Document dom;
         public JobLogDetails3(){
              //create a list to hold the job objects
              myJobs = new ArrayList();
         public void runJobDetails() {
              //parse the xml file and get the dom object
              parseXmlFile();
              //get each joblog element and create a job object
              parseDocument();
              //Iterate through the list and print the data
              printData();
         private void parseXmlFile(){
              //get the factory
              DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
              try {
                   //Using factory get an instance of document builder
                   DocumentBuilder db = dbf.newDocumentBuilder();
                   //parse using builder to get DOM representation of the XML file
                   dom = db.parse("test.xml");
              }catch(ParserConfigurationException pce) {
                   pce.printStackTrace();
              }catch(SAXException se) {
                   se.printStackTrace();
              }catch(IOException ioe) {
                   ioe.printStackTrace();
         private void parseDocument(){
              //get the root elememt
              Element docEle = dom.getDocumentElement();
              //get a nodelist of <joblog> elements
              NodeList nl = dom.getElementsByTagName("*");
              if(nl != null && nl.getLength() > 0) {
                   for(int i = 0 ; i < nl.getLength();i++) {
                        //get the joblog element
                        Element el = (Element)nl.item(i);
                        //get the joblog object
                        Job J = getJob(el);
                        //add it to list
                        myJobs.add(J);
         * I take an joblog element and read the values in, create
         * an joblog object and return it
         * @param JobEl
         * @return
         private Job getJob(Element JobEl) {
              //for each <joblog> element get text or int values of
              //name ,id, age and name
              String jobServer = getTextValue(JobEl,"server");
              String jobName = getTextValue(JobEl,"name");
              String jobClient = getTextValue(JobEl,"machine_name");
              String jobStart = getTextValue(JobEl,"start_time");
              String jobType = getTextValue(JobEl,"type");
              String jobEnd = getTextValue(JobEl,"end_time");
              String jobSize = getTextValue(JobEl,"new_processed_bytes");
              //Create a new Job with the value read from the xml nodes
              Job J = new Job(jobServer,jobName,jobClient,jobStart,jobType,jobEnd,jobSize);
              return J;
         * I take a xml element and the tag name, look for the tag and get
         * the text content
         * i.e for <employee><name>John</name></employee> xml snippet if
         * the Element points to employee node and tagName is name I will return John
         * @param ele
         * @param tagName
         * @return
         private String getTextValue(Element ele, String tagName) {
              String textVal = null;
              NodeList nl = ele.getElementsByTagName(tagName);
              if(nl != null && nl.getLength() > 0) {
                   Element el = (Element)nl.item(0);
                   textVal = el.getFirstChild().getNodeValue();
              return textVal;
         * Calls getTextValue and returns a int value
         * @param ele
         * @param tagName
         * @return
         private int getIntValue(Element ele, String tagName) {
              //in production application you would catch the exception
              return Integer.parseInt(getTextValue(ele,tagName));
         * Iterate through the list and print the
         * content to console
         private void printData(){
              System.out.println("No of Jobs '" + myJobs.size() + "'.");
              Iterator it = myJobs.iterator();
              while(it.hasNext()) {
                   System.out.println(it.next().toString());
         public static void main(String[] args){
              //create an instance
              JobLogDetails JLD = new JobLogDetails();
              //call run example
              JLD.runJobDetails();
    Job Class
    public class Job {
         private String jobServer;
    private String jobName;
    private String jobClient;
    private String jobStart;
    private String jobType;
    private String jobEnd;
    private String jobSize;
         public Job(){
         public Job(String jobServer,String jobName,String jobClient,String jobStart,String jobType,String jobEnd,String jobSize ) {
              this.jobServer = jobServer;
              this.jobName = jobName;
              this.jobClient = jobClient;
    this.jobStart = jobStart;
              this.jobType = jobType;
    this.jobEnd = jobEnd;
    this.jobSize = jobSize;
         public String getjobServer() {
              return jobServer;
         public void setjobServer(String jobServer) {
              this.jobServer = jobServer;
         public String getjobName() {
              return jobName;
         public void setjobname(String jobName) {
              this.jobName = jobName;
         public String getjobClient() {
              return jobClient;
         public void setjobClient(String jobClient) {
              this.jobClient = jobClient;
    public String getjobStart() {
              return jobStart;
         public void setjobStart(String jobStart) {
              this.jobStart = jobStart;
    public String getjobType() {
              return jobType;
         public void setjobType(String jobType) {
              this.jobType = jobType;
    public String getjobEnd() {
              return jobEnd;
         public void setjobEnd(String jobEnd) {
              this.jobEnd = jobEnd;
    public String getjobSize() {
              return jobSize;
         public void setjobSize(String jobSize) {
              this.jobSize = jobSize;
         public String toString() {
              StringBuffer sb = new StringBuffer();
    sb.append(getjobServer());
              sb.append(",");
    sb.append(getjobName());
              sb.append(",");
              sb.append(getjobClient());
              sb.append(",");
              sb.append(getjobType());
              sb.append(",");
              sb.append(getjobStart());
              sb.append(",");
              sb.append(getjobEnd());
              sb.append(",");
              sb.append(getjobSize());
              sb.append(",");
              return sb.toString();
    Sample XML File:
    <?xml version="1.0" encoding="UTF-16" ?>
    - <joblog>
    <job_log_version version="2.0" />
    - <header>
    <filler>======================================================================</filler>
    <server>Job server: TGBBAK</server>
    <name>Job name: TGBSAP4-SQL-SQL DB Servers S2T - High-Weekly Full Backup</name>
    <start_time>Job started: 26 September 2011 at 01:00:04</start_time>
    <type>Job type: Backup</type>
    <log_name>Job Log: GFD_TGBBAK_71887.xml</log_name>
    <filler>======================================================================</filler>
    </header>
    <media_mount_date>Drive and media mount requested: 26/09/2011 01:00:04</media_mount_date>
    - <media_drive_and_media_info>
    <media_mount_date>Drive and media information from media mount: 26/09/2011 01:00:39</media_mount_date>
    <robotic_library_name>Robotic Library Name: HP 1</robotic_library_name>
    <drive_name>Drive Name: LTO4_2</drive_name>
    <slot>Slot: 43</slot>
    <media_label>Media Label: 000059L</media_label>
    <media_guid>Media GUID: {a6ca0062-7a6f-4b4b-8144-732ca25f2f9d}</media_guid>
    <media_overwrite_date>Overwrite Protected Until: 25/10/2011 19:24:58</media_overwrite_date>
    <media_append_date>Appendable Until: 02/10/2011 14:00:30</media_append_date>
    <media_set_target>Targeted Media Set Name: Weekly Tape</media_set_target>
    </media_drive_and_media_info>
    - <backup>
    <filler>======================================================================</filler>
    <title>Job Operation - Backup</title>
    <append_or_overwrite>Media operation - append.</append_or_overwrite>
    <compression>Compression Type: Hardware [if available, otherwise none]</compression>
    <verify_option>WARNING: The option 'Verify after backup completes' was not selected. Performing a verify operation to make sure that media can be read after the backup has completed is recommended.</verify_option>
    <filler>======================================================================</filler>
    - <machine>
    <machine_name>TGBSAP4.Tetley.Grp</machine_name>
    <info>Network control connection is established between 10.22.2.18:3271 <--> 10.22.2.4:10000</info>
    <info>Network data connection is established between 10.22.2.18:3301 <--> 10.22.2.4:3094</info>
    - <set>
    <set_resource_name>TGBSAP4.Tetley.Grp</set_resource_name>
    <tape_name>Family Name: "Media created 25/09/2011 13:59:55"</tape_name>
    - <volume>
    <display_volume>Backup of "TGBSAP4.Tetley.Grp "</display_volume>
    </volume>
    <description>Backup set #45 on storage media #1 Backup set description: "Weekly Full Backup"</description>
    <backup_type>Backup Method: Full - Back up entire database or filegroup</backup_type>
    <agent_started>Microsoft SQL Server Agent: Started</agent_started>
    <start_time>Backup started on 26/09/2011 at 01:01:45.</start_time>
    - <database>
    <database>Database PRD</database>
    </database>
    - <database>
    <database>Database master</database>
    </database>
    - <database>
    <database>Database model</database>
    </database>
    - <database>
    <database>Database msdb</database>
    </database>
    <end_time>Backup completed on 26/09/2011 at 02:42:25.</end_time>
    - <summary>
    <backed_up_database>Backed up 4 databases</backed_up_database>
    <new_processed_bytes>Processed 573363576542 bytes in 1 hour, 40 minutes, and 40 seconds.</new_processed_bytes>
    <vlm_hist_rateformat2>Throughput rate: 5432 MB/min</vlm_hist_rateformat2>
    </summary>
    <filler>----------------------------------------------------------------------</filler>
    </set>
    </machine>
    </backup>
    - <footer>
    <filler>======================================================================</filler>
    <end_time>Job ended: 26 September 2011 at 02:43:12</end_time>
    <engine_completion_status>Job completion status: Successful</engine_completion_status>
    <filler>======================================================================</filler>
    <completeStatus>19</completeStatus>
    </footer>
    </joblog>

    1. your code does not compile (in your main method you try to create an instance of a class which does not exist).
    2. your XML document is not well formed.
    +[Fatal Error] test.xml:34:74: The content of elements must consist of well-formed character data or markup.+
    org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
    Maybe there are other problems but you can start by fixing these.

  • How to parse xml file

    Hi,
    I am having an XML file which is having set of repeated tags like
    <gender>
    <male>
    <name>sk</name>
    <age>19</age>
    </male>
    <male>
    <name>raj</name>
    <age>20</age>
    </male>
    <male>
    <name>kris</name>
    <age>18</age>
    </male>
    </gender>
    Like this i am having the xml file, i have to read the values from this xml file, here we are having male tag is repeated, from this i have to take the name, and age values. can you tell me how to take these values. If you are having the sample send me.
    Thanks,

    Hai
    It may be a bit late to reply but i hope this code will help you
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import java.io.*;
    import java.io.File;
    import org.w3c.dom.*;
    class DomParse
         public void func()
              try               
                   DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();               
                   DocumentBuilder db = dbf.newDocumentBuilder();               
                   //File f =new File("trial.xml");
                   Document doc = db.parse(new File("trial.xml")); //your xml file name here
                   //Document doc = db.parse(f);
                   NodeList nl1 = doc.getElementsByTagName("male");
                   for(int i=0;i<nl1.getLength();i++)
                        Node nd = nl1.item(i);
                        NodeList tmplist = nd.getChildNodes();
                        for(int j=0;j<tmplist.getLength();j++)
                             Node tmpNode = tmplist.item(j);
                             String locStr = tmpNode.getTextContent();
                             System.out.println(""+tmpNode.getTextContent());
              catch(Exception e)
                   System.out.println("Error: "+e);
                   e.printStackTrace();
         public static void main(String[] args) //throws
              new DomParse().func();
    with regards
    shan

  • How to parse xml file to read the tags

    Hi All,
    I am having a requirement to read the tags from the xml file(xml parsing).
    The main issue is *xml file is stored in the table with xml type column* (not placed directly in the server) and we have to read the tags from that xml file.
    Please help me to achieve it.
    Regards,
    Akshata
    Edited by: Akshata on Mar 21, 2013 3:44 AM

    Hi,
    Akshata wrote:
    The main issue is xml file is stored in the table clob/blob type column (not placed directly in the server) and we have to read the tags from that xml file.How is that an issue? On the contrary, it's better when the data already resides in the database, though it should be in an XMLType column to leverage the full capacity of the Oracle parser.
    What's the datatype of the column exactly? CLOB or BLOB?
    Either way you'll have to convert in to XMLType datatype using the XMLType constructor.
    Did you go through the countless examples on this forum? Examples with XMLTable should be helpful.
    Post some sample data and database version if you need additional guidance.
    Thanks.

  • 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.

  • Parse xml file with validating againat dtd

    i have a xlm file looks like:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE map SYSTEM "map.dtd">
    <map width="20" height="15" goal="25" name="eXtreme Labyrinth of Dooom">
    <random-item type='lantern' amount='5' />
    <random-item type='health' amount='10' />
    <tile x="14" y="0" type="wall">
    <renderhint>wall:rock,cracked</renderhint>
    </tile>
    <tile x="15" y="0" type="wall" />
    <tile x="16" y="0" type="floor">
    <renderhint>floor:marble,cracked</renderhint>
    </tile>
    <tile x="17" y="0" type="floor">
    <renderhint>floor:stone,rubble</renderhint>
    </tile>
    <tile x="18" y="0" type="floor" />
    <tile x="0" y="1" type="floor" />
    <tile x="1" y="1" type="floor" startlocation="1" />
    <tile x="2" y="1" type="floor" />
    <tile x="3" y="1" type="floor">
    <item type="treasure">Bar of Silver</item>
    <renderhint>floor:stone,blood</renderhint>
    </tile>
    <tile x="4" y="1" type="wall" />
    <tile x="5" y="1" type="wall" />
    <tile x="6" y="1" type="wall">
    <renderhint>wall:bricks,cracked</renderhint>
    </tile>
    </map>and a dtd document like:
    <!ELEMENT map (random-item+, tile+)>
    <!ATTLIST map
    width CDATA #REQUIRED
    height CDATA #REQUIRED
    goal CDATA #REQUIRED
    name CDATA #REQUIRED
    <!ELEMENT random-item EMPTY>
    <!ATTLIST random-item
    type (armour|health|sword|treasure|lantern) #REQUIRED
    amount CDATA #REQUIRED
    <!ELEMENT tile (item|renderhint)*>
    <!ATTLIST tile
    x CDATA #REQUIRED
    y CDATA #REQUIRED
    type (exit|floor|wall) #REQUIRED
    startlocation CDATA #IMPLIED
    <!ELEMENT item (#PCDATA)>
    <!ATTLIST item
    type (armour|health|sword|treasure|lantern) #REQUIRED
    <!ELEMENT renderhint (#PCDATA)>i need to validate the xml file against the dtd document and parse it to java using DOM.
    Can anyone give ma any suggestions on how to do it?
    thank you

    i have started my coding like:
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.ParserConfigurationException;
    import org.w3c.dom.*;
    import org.xml.sax.SAXException;
    import java.io.*;
    class loadxml
        public static void main(String[] args)
         try {
              DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
              factory.setValidating(true);
              factory.setIgnoringElementContentWhitespace(true);
              DocumentBuilder parser = factory.newDocumentBuilder();
              Document doc = parser.parse(new File("hallways.xml"));
              loadxml load = new loadxml();
              load.parseNode(doc);
         } catch (ParserConfigurationException e) {
              e.printStackTrace();
         } catch (SAXException e) {
              e.printStackTrace();
         } catch (IOException e) {
              e.printStackTrace();
        public void parseNode (Node node) throws IOException
               // here is where i have problem with
    }since in my xml file, i have got ATTLIST, this ready confuses me when i try to coding it.
    Can anyone help me, please.
    Thank you.
    Edited by: mujingyue on Mar 12, 2008 3:10 PM

  • Need help processing XML files

    I'm fairly new to Java and have never worked with XML. I need to process several XML files and display them in a matrix for comparison and I'm not sure if I need to understand SAX, DOM or some other API. I'm not creating the files, I'm just parsing them to put into a table so they can be displayed for comparison. I could be processing up to several hundreds of files, so performance would also be an issue.
    I'm just looking for options and possible areas I can begin to look for help. Can anyone tell me which APIs would help me acheive my goal?
    Any help would be greatly appreciated.
    Thanks

    Thanks for the response Kev. I guess a better diescription of the problem would be to say that I want to display the attributes and values of the differnet files in a matrix.
    For example...
    Here are 2 sample xml files with the same tags and attributes.
    XML FILE A
    <tag1 name="Fred", country="ca">
    <tag2 group-name="Group 1">
    <tag3 color ="blue">
    </tag3>
    </tag2>
    </tag1>
    XML FILE B
    <tag1 name="Sue", country="us">
    <tag2 group-name="Group 2">
    <tag3 color="red">
    </tag3>
    </tag2>
    </tag1>
    I would like to have them displayed as follows...
    XML FILE A XML FILE B
    tag1 name           Fred Sue
    tag1 country           ca us
    tag2 group-name          Group 1 Group 2
    tag3 Color          Blue     Red
    HTML tags didn't work, so the matrix is bunched together, but I think you get the idea. My question is, which would be better to use SAX or DOM. I could be running this on as many as 50 or 60 files, so the matrix could get very large and performance could be an issue as multiple users could be doing this comparison at the same time.

Maybe you are looking for

  • Cannot set up Firefox sync on desktop - no recovery key and will not let me login to get it

    I downloaded Firefox for my new android phone and wanted to sync my desktop with the mobile app. When I first went in it said I had an account already set up, but since I didn't remember any of the information about it I just ended up changing the pa

  • Animated (up state) button image quality

    Hello, I am experienced with Captivate and getting familiar with Flash MX. I am having trouble with loss of detail (blurry images) when importing flash into Captivate. In flash, I've created a simple button. It has a movie clip in its up state that m

  • Nowhere can input reason code in function BAPI_ACC_DOCUMENT_POST

    Hi..... Field Reason code is a required field for a G/L account,But it seems that nowhere can input it in function BAPI_ACC_DOCUMENT_POST's table parameter ACCOUNTGL.Thus I can use this function to create Accounting Document .....How can I solve it ?

  • Stop JScrollPane Scrolling If Knob Is Not At Bottom

    My problem appears quite simple. I have a non-editable JTextArea in a JScrollPane. When text is added to the text area I want the vertical JScrollBar to autoscroll only if the knob is at the bottom of the track. If the user has scrolled up (e.g. to s

  • FRM-40010 when opening custom form in Forms6i

    Hello, I'm running an instance of the E-Business Suite 11.5.10.2, which uses Forms Developer 6i. I recently upgrated to patchset 19, and now, I go to my custom apps login URL, and get the following error: http://ppc-oradev.purchasingpwr.com:8000/dev6