How parse XML document for output

I have this users.xml document :
<?xml version="1.0" ?>
<!DOCTYPE users[
<!ELEMENT users (user+) >
<!ELEMENT user (mail,password)+ >
<!ELEMENT mail (#PCDATA)>
<!ELEMENT password (#PCDATA)>
<!ATTLIST userid CDATA #REQUIRED >
] >
<users>
<user id='3'>
  <mail> [email protected]</mail>
  <password>password 11</password>
</user>
<user id='4'>
  <mail>[email protected]</mail>
  <password>password 21</password>
  <mail>[email protected]</mail>
  <password>password 22</parola>
</user>
</users>I want to have this output :
id=3 [email protected] password 11
id=4 [email protected] password 21
id=4 [email protected] password 22
I have no idee what i should use (in java) here pls help me !
Thank you !

You want to have a look at JAXP (Java API for XML Processing), start here [http://java.sun.com/j2ee/1.4/docs/tutorial/doc/|http://java.sun.com/j2ee/1.4/docs/tutorial/doc/] (e.g. chapter 6)
Edited by: pierrepost on Jun 16, 2008 3:13 PM

Similar Messages

  • Parse XML document which have xlink/xpointer inside

    dear friends,
    There are lots of topic talking about parse xml, validating xml with schema and so on, but no one or any book talking about parsing xml document which can parse document with link inside.
    According to Mr Meggison at http://www.megginson.com/Background/
    we can do it, but he is not expert with this thing.
    For example I have 3 XML document. My main XML document, let named it A.XML have XPointer inside and this element pointing to B.XML and C.XML using xpointer. how to parse A.XML and in the same time my SAX recognized this XPointer and parse also element inside B.XML and C.XML.
    I am really grateull for any helpful information from you.
    best regards

    I think you need to look for a SAX or DOM parser that undestands XPointers and knows how to follow them to additional content.
    I have used XSLT and specified external documents to it. It knows how to read a document and in effect make a nodeset which can be searched with the XPath capabilities of XSLT.
    It sounds like you wnat an <include file="xxx"/> capability and have the parser stop reading the current file, and start reading the second file.
    That works in Schemas, but I'm unaware of any way to do it with SAX or DOM in one pass.
    It would not be too hard to process the first file, say with DOM.
    After the Document is built, go find the <include> elements, read get the attribute needed, build a new Document and merge it into the original Document in place of the <include> element.
    Is this more what you want to do?
    Dave Patterson

  • How to parse XML document returned by webservices

    Hi,
    I have a form (version 10.1.2.0) which has to display the credit card types using webservices. I created the webstub and jar file through jdeveloper and then after adding the jar files in the respective classpaths, I import it in the forms. I write the code in when-button-pressed and it gives the result in xml document like this:
    <?xml version="1.0" encoding="UTF-8"?><WSAnswerTO><error>false</error><errorMessage></errorMessage><
    results><CardTypeTO><carTypId>3</carTypId><type>AMERICAN
    EXPRESS</type><numLength>15</numLength><cvvLength>4</cvvLength><comments>1 800-639-0002</comments></CardTypeTO><CardTypeTO><carTypId>4</carTypId><type>DISCOVER</type><numLength>16</numLength><cvvLength>3</cvvLength><comments>1 800-347-2683</comments></CardTypeTO><CardTypeTO><carTypId>1</carTypId><type>MASTERCARD</type><numLength>16</numLength><cvvLength>3</cvvLength><comments>1 800-633-7367</comments></CardTypeTO><CardTypeTO><carTypId>2</carTypId><type>VISA</type><numLength>16</numLength><cvvLength>3</cvvLength><comments>1 800-945-2000</comments></CardTypeTO></results></WSAnswerTO>
    From the above xml document, I only need to display the type (such as AMERICAN EXPRESS, VISA, ETC) in my forms. Can somebody please tell me how to do it. Do I need to store the values in a table first and then retrieve it. Please advise. I have already read a otn document in xml parsing but I didnt understand anything from it.
    Please help. Thanks in advance.

    Hello,
    It probably exists a database package/function to parse this kind of stuff.
    If you want to keep the process into the Forms, here is a PL/SQL package you can use:
    CREATE OR REPLACE PACKAGE Pkg_Tools AS
      --  Types  --
      -- table of strings --
      TYPE TYP_TAB_CHAR IS TABLE OF VARCHAR2(4000) INDEX BY BINARY_INTEGER;
      --  Methodes   --
      -- function that return all contents for a given XML tag --
      FUNCTION Get_Xml_Tag
         PC$XmlContent  IN VARCHAR2,                 -- XML string
         PC$Tag         IN VARCHAR2,                 -- searched tag
         PC$NewLine     IN VARCHAR2 DEFAULT CHR(10)  -- defaull NL character
      RETURN TYP_TAB_CHAR ;
    END Pkg_Tools;
    CREATE OR REPLACE PACKAGE BODY Pkg_Tools
    IS
      -- fonction de retour du contenu d'une balise XML  --
      FUNCTION Get_Xml_Tag
         PC$XmlContent  IN VARCHAR2,                 -- contenu XML
         PC$Tag         IN VARCHAR2,                 -- tag recherche
         PC$NewLine     IN VARCHAR2 DEFAULT CHR(10)  -- defaull NL character
      RETURN TYP_TAB_CHAR
      IS
       TC$Table      TYP_TAB_CHAR ;
       LC$Ligne      VARCHAR2(32000) ;
       LC$Xml        VARCHAR2(32000) ;
       LN$INDEX      PLS_INTEGER := 0 ;
       LN$TagDeb     PLS_INTEGER ;
       LN$TagFin     PLS_INTEGER ;
       LN$TagLength  PLS_INTEGER ;
       LN$LigLength  PLS_INTEGER ;
       LN$Occur      PLS_INTEGER := 1 ;
      BEGIN
        IF ( PC$XmlContent IS NOT NULL AND PC$Tag IS NOT NULL ) THEN
          LC$Xml := REPLACE( PC$XmlContent, CHR(13), '' ) ;
          LN$TagLength := LENGTH( PC$Tag ) ;
           LOOP
          LN$TagDeb := INSTR( LC$Xml, PC$Tag, 1, LN$Occur ) ;
          LN$TagFin := INSTR( LC$Xml, '</' || SUBSTR(PC$Tag,2, 256), 1, LN$Occur ) ;
          LN$LigLength := (LN$TagFin - ( LN$TagDeb + LN$TagLength ) ) ;
          IF (LN$TagDeb > 0 AND LN$TagFin > 0 ) THEN
             LN$Occur := LN$Occur + 1 ;
             LC$Ligne := SUBSTR( LC$Xml, LN$TagDeb + LN$TagLength, LN$LigLength ) ;
             LOOP
               LN$INDEX := LN$INDEX + 1 ;
               LN$TagDeb := INSTR( LC$Ligne, PC$NewLine ) ;
               IF LN$TagDeb > 0 THEN
                 IF Trim( SUBSTR( LC$Ligne, 1, LN$TagDeb - 1 )) IS NOT NULL THEN
                   TC$Table(LN$INDEX) := SUBSTR( LC$Ligne, 1, LN$TagDeb - 1 ) ;
                 ELSE
                   LN$INDEX := LN$INDEX - 1 ;
                 END IF ;
                 LC$Ligne := SUBSTR( LC$Ligne, LN$Tagdeb + LENGTH( PC$NewLine ), 30000 ) ;
               ELSE
                 IF Trim(LC$Ligne) IS NOT NULL THEN
                    TC$Table(LN$INDEX) := LC$Ligne ;
                 END IF ;
                 EXIT ;
               END IF ;
             END LOOP ;
          ELSE
              EXIT ;
          END IF ;
           END LOOP ;
        END IF ;
        RETURN TC$Table ;
      END Get_Xml_Tag ;
    END Pkg_Tools;
    /Then the call:
    DECLARE
       LC$t  VARCHAR2(2000);
       LT$Table Pkg_Tools.TYP_TAB_CHAR ;
    BEGIN
       lc$t := '<?xml version="1.0" encoding="UTF-8"?><WSAnswerTO><error>false</error><errorMessage></errorMessage><results>'
    ||'<CardTypeTO><carTypId>3</carTypId><TYPE>AMERICAN EXPRESS</TYPE><numLength>15</numLength><cvvLength>4</cvvLength>'
    ||'<comments>1 800-639-0002</comments></CardTypeTO><CardTypeTO><carTypId>4</carTypId><TYPE>DISCOVER</TYPE>'
    ||'<numLength>16</numLength><cvvLength>3</cvvLength><comments>1 800-347-2683</comments></CardTypeTO>'
    ||'<CardTypeTO><carTypId>1</carTypId><TYPE>MASTERCARD</TYPE><numLength>16</numLength><cvvLength>3</cvvLength>'
    ||'<comments>1 800-633-7367</comments></CardTypeTO><CardTypeTO><carTypId>2</carTypId><TYPE>VISA</TYPE>'
    ||'<numLength>16</numLength><cvvLength>3</cvvLength><comments>1 800-945-2000</comments></CardTypeTO></results></WSAnswerTO>' ;
       LT$Table := Pkg_Tools.Get_Xml_Tag(LC$T,'<TYPE>') ; 
       IF LT$Table.COUNT > 0 THEN
         FOR i IN LT$Table.First .. LT$Table.Last LOOP
            dbms_output.put_line( 'Table(' || i || ')=' || LT$Table(i) ) ;
         END LOOP ;
       ELSE
         dbms_output.put_line( 'tag xml not found' ) ;
       END IF ;
    END;Francois

  • How to ignore white space when parse xml document using xerces 2.4.0

    When I run the program with the xml given below the following error comes.
    Problem parsing the file.java.lang.NullPointerExceptionjava.lang.NullPointerExce
    ption
    at SchemaTest.main(SchemaTest.java:25)
    ============================================================
    My expectation is "RECEIPT". Pls send me the solution.
    import org.apache.xerces.parsers.DOMParser;
    import org.xml.sax.InputSource;
    import java.io.*;
    import org.xml.sax.ErrorHandler;
    import org.w3c.dom.*;
    public class SchemaTest {
    public static void main (String args[])
    try
    FileInputStream is = new FileInputStream(new File("C:\\ADL\\imsmanifest.xml"));
    InputSource in = new InputSource(is);
    DOMParser parser = new DOMParser();
    //parser.setFeature("http://xml.org/sax/features/validation", false);
    //parser.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation", "memory.xsd");
    //ErrorHandler errors = new ErrorHandler();
    //parser.setErrorHandler(errors);
    parser.parse(in);
    Document manifest = parser.getDocument();
    manifest.normalize();
    NodeList nl = manifest.getElementsByTagName("organization");
    System.out.println((((nl.item(0)).getChildNodes()).item(0)).getFirstChild().getNodeValue());
    catch (Exception e)
    System.out.print("Problem parsing the file."+e.toString());
    e.printStackTrace();
    <?xml version = '1.0'?>
    <organizations default="detail">
    <organization identifier="detail" isvisible="true">
    <title>RECEIPT</title>
    <item identifier="S100000" identifierref="R100000" isvisible="true">
    <title>Basic Module</title>
    <item identifier="S100001" identifierref="R100001" isvisible="true">
    <title>Objectives</title>
    <metadata/>
    </item>
    </item>
    <metadata/>
    </organization>
    </organizations>
    Is there a white space problem? How do I get rid from this problem.

    ok now i really wrote the whole code, a bit scrolling in the API is to hard?
                DocumentBuilderFactory dbf = new DocumentBuilderFactory();
                DocumentBuilder db = dbf.newDocumentBuilder();
                dbf.setNamespaceAware(true); //or set false
                Document d = db.parse(inputstream);

  • Loading XML document for DOM parsing

    Can anyone suggest other API's to load a XML document into memory so they can be parsed using the DOM with Java?(e.g. The "load(url)" interface method specific to IE5)
    Thanks

    Check out the DOMSample.java code came with the XML Parser for Java v2 download.
    Oracle XML Team

  • Invalid testsuite XML document for junitreport task

    Hi everyone, I'm new to this forum and apologies if this is the incorrect place for me to post this thread. Basically I'm having some issues with the junitreport task with my junit test project.
    I have a dummy class called Money and dummy test suite called MoneyTest that contains 4 test cases. The test is run through ANT <junit> task and they all passed with no problems. The problem occurred when I tried to perform the automatic test report generation using <junitreport> task, and the generated HTML pages contain no test results at all, indicated by "Tests:0 Failures:0 Errors:0 Success rate:0 Time:0.000" (in which case it should be 4 for Tests, etc.).
    The error message says "TESTS-TestSuites.xml is not a valid testsuite XML document". I assume this file is auto-generated by the <junitreport> task which defines how the output HTML should look like. However, it only contains the folloing 2 lines:<?xml version="1.0"?> <testsuites />. I suspect this should be the cause of the empty output. So could anyone who's familar with this issue shed any light on how I should go about deal with this issue please? Thank you very much in advance!
    By the way, the task code in build.xml for reporting is as follows:
    <target name="report">
         <junitreport todir="./reports">
              <fileset dir="./reports" includes="*.xml" />
              <report format="frames" todir="./report/html" />
         </junitreport>
    </target>

    Thanks, the issue has been solved. I simply forgot to set the formatter type to xml in the junit task.

  • Parsing xml document

    <?xml version="1.0" ?>
    </result>
    <response xmlns="http://comnet.com/namespaces/wcm/appint/1.0">      <objectset>
    <objectstore>                               <id>{275F7BDB-6F42-4CC1-99A3-59134AE30C38}</id>                <name>Alaska</name>
         <properties>
         <property>
         <name>Display Name</name>                     <value>Alaska</value>                     <symname>DisplayName</symname>                <datatype>8</datatype>
         </property>
                   </properties>
    </objectstore>
    <objectstore>                               <id>{98FA40B5-A425-4092-85D4-9BBD61A77E6F}</id>                <name>Yukon Territory</name>
              <properties>
         <property>
         <name>Display Name</name>                <value>Yukon Territory</value>                <symname>DisplayName</symname> <datatype>8</datatype>
    </property>
    </properties>      </objectstore>
    <count>2</count>
    </objectset>
    </response>
    </result>
    </appintresponse>
    hi this my xml document.i trying to parse this document..
    i need to display the id and name values of each objectstore tag in a select box
    id as option value and name as option text.
    iam doing like this..
    e = doc.getDocumentElement();
    list = e.getElementsByTagName("name");
    for(int i = 0; i < list.getLength(); i++)
    n = list.item(i);
    if(n.hasChildNodes())
    list2 = n.getChildNodes();
    for(int j = 0; j < list2.getLength(); j++)
    n2 = list2.item(j);
    String name =n2.getNodeValue();
                                                      out.println(name);
    it displaying the name but also its displaying the value which is name tag of property element..how can i avoid this..
    regards,

    as <id> is a child of <ObjectStore> it would seem that you should getElementsByName("ObjectStore") first, then find the id and name children.

  • Invalid xml document for BPEL Process.

    Hi everyone,
    I am getting below error after i set validateXML=strict
    Invalid xml document.
    According to the xml schemas, the xml document is invalid. The reason is: Error::cvc-datatype-valid.1.2.1: '' is not a valid value for 'decimal'.
    Error::cvc-type.3.1.3: The value '' of element 'ns1:p_person_id' is not valid.
    Please make sure that the xml document is valid against your schemas.
    Kindly help me with the steps. I am just a SOA admin, not developer.
    Regards
    Lammeki.

    Ummmm Vikas,
    Lemme bring out a better picture, so u get more clear on this one.
    The developer has upgraded an already deployed BPEL process.
    Since then, she has been facing problem. When she invoke those process they simply end up as faulted with a yellow color ! mark.
    Now i as an admin, i tried everything to help her cos she escalated the issue to me, thinking maybe there is sumthing i could do to assists her.
    Now i am not sure, how to help her, but yes i started with the logs. Both the oc4j container log for SOA and the domain log show the similar error.
    But till then, i didn't know black and white of it. so i tried doing all testing possible from my end.
    When i check on the faulted instances i see there is a Assign activity after Transform followed by Invoked being highlighted in red color. and when i clicked on it i get to see the error
    Assign_41
    [2011/07/21 02:26:15]
    Error in evaluate <from> expression at line "315". The result is empty for the XPath expression : "/ns6:QueryPerAllPeopleOutputCollection/ns6:QueryPerAllPeopleOutput/ns6:EMPLOYEE_NUMBER".
    oracle.xml.parser.v2.XMLElement@1ee216f
    Copy details to clipboard
    [2011/07/21 02:26:15]
    "{http://schemas.xmlsoap.org/ws/2003/03/business-process/}selectionFailure" has been thrown.
    - <selectionFailure xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/">
    - <part name="summary">
    <summary>
    empty variable/expression result.
    xpath variable/expression expression "/ns6:QueryPerAllPeopleOutputCollection/ns6:QueryPerAllPeopleOutput/ns6:EMPLOYEE_NUMBER" is empty at line 315, when attempting reading/copying it.
    Please make sure the variable/expression result "/ns6:QueryPerAllPeopleOutputCollection/ns6:QueryPerAllPeopleOutput/ns6:EMPLOYEE_NUMBER" is not empty.
    Possible reasons behind this problems are: some xml elements/attributes are optional or the xml data is invalid according to XML Schema.
    To verify whether XML data received by a process is valid, user can turn on validateXML switch at the domain administration page.
    </summary>
    </part>
    </selectionFailure>
    Copy details to clipboard
    So because of that instruction i went ahead and set validateXML=strict
    and that is when i got the error message as below
    Invoke_PerAllPeople
    [2011/07/21 11:47:12]
    Invalid data: The value for variable "Invoke_PerAllPeople_QueryPerAllPeople_InputVariable", part "QueryPerAllPeopleInput_msg" does not match the schema definition for this part.The invalid xml document is shown below:
    oracle.xml.parser.v2.XMLElement@17f54ff
    Copy details to clipboard
    [2011/07/21 11:47:12]
    Faulted while invoking operation "QueryPerAllPeople" on provider "QueryPerAllPeople".
    - <messages>
    - <input>
    - <Invoke_PerAllPeople_QueryPerAllPeople_InputVariable>
    - <part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="QueryPerAllPeopleInput_msg">
    - <QueryPerAllPeopleInput xmlns:ns1="http://xmlns.oracle.com/pcbpel/adapter/db/QueryPerAllPeople" xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/QueryPerAllPeople">
    <ns1:p_person_id/>
    </QueryPerAllPeopleInput>
    </part>
    </Invoke_PerAllPeople_QueryPerAllPeople_InputVariable>
    </input>
    - <fault>
    - <invalidVariables xmlns="http://schemas.oracle.com/bpel/extension">
    - <part name="code">
    <code>
    9710
    </code>
    </part>
    - <part name="summary">
    <summary>
    Invalid xml document.
    According to the xml schemas, the xml document is invalid. The reason is: Error::cvc-datatype-valid.1.2.1: '' is not a valid value for 'decimal'.
    Error::cvc-type.3.1.3: The value '' of element 'ns1:p_person_id' is not valid.
    Please make sure that the xml document is valid against your schemas.
    </summary>
    </part>
    </invalidVariables>
    </fault>
    </messages>
    Copy details to clipboard
    [2011/07/21 11:47:12]
    "{http://schemas.oracle.com/bpel/extension}invalidVariables" has been thrown.
    - <invalidVariables xmlns="http://schemas.oracle.com/bpel/extension">
    - <part name="code">
    <code>
    9710
    </code>
    </part>
    - <part name="summary">
    <summary>
    Invalid xml document.
    According to the xml schemas, the xml document is invalid. The reason is: Error::cvc-datatype-valid.1.2.1: '' is not a valid value for 'decimal'.
    Error::cvc-type.3.1.3: The value '' of element 'ns1:p_person_id' is not valid.
    Please make sure that the xml document is valid against your schemas.
    </summary>
    </part>
    </invalidVariables>
    Copy details to clipboard
    The main problem was we were observing many SOA inactive threads in one particular database, and they keep building up minutes by minutes.
    I suspect, that in the code connections were open but were not closed, there4 there were inactive threads in the database.
    I had to stop the SOA application, to stop threads from building up. I guess they got build up when they were invoked. There is definitely some fault with the code. or tell me am wrong. tell me its sumthing else.
    However other domains processes were working fine.
    and oh, yes the developer also made changes in the database. when i asked her to revert back and see if it works, she say thats a huge amount of work.
    Finally she end up saying that maybe it could be a problem with the new version.
    Now as a learner, I want to know what is going on, and how do we go about solving it.
    Am not much of a SOA techie. that u can make out. but yes ready to learn things. so there4 i beg you to explain to me like am a standard 3 or 4 kid. any more information needed plz feel free to write back.
    regards
    Lammeki.

  • Parse XML document ,create table according to tags &  load data to  table

    Hi All!
    I have one of the most common problem, one faces when dealing with xml stuff and oracle.I get xml documents, with each file having different tags.I want to write a pl/sql procedure such that, the xml file is parsed, a table is created with the tag names becoming the column names and all the nodes' data get inserted into the table as rows.I am using oracle 10g.
    I read a thread at the following url:
    Parse XML and load into table
    But did not get much of it.
    Can anybody please tell me how to accomplish this.
    Thanking in advance.
    Regards,
    Deepika.

    Why do people have such an aversion to the XML DB forum for XML questions...
    See FAQ for XML DB forum here: XML DB FAQ
    Explains all about getting XML into tables in the database.

  • Need help in Parsing XML Document in Oracle

    Hello Experts,
    I urgently need your help. We have xml document on the Web but not on the File System. How can I parse the xml document on the web in Oracle.
    Any link, blog or sample code would be appreciated.
    Your help would be appreciated.
    Kind Regards,
    Bhavin
    London, UK

    This breaks down to two issues
    1) Getting the XML into Oracle
    2) Parsing the XML inside Oracle
    For #1, the first two options that come to my mind are httpuirtype and utl_http. Both can be used to get information from a URL that understands HTTP requests.
    For #2, you can treat the XML as a DOMDocument or XMLType to parse it. You also could parse it via a SQL statement using XQuery or XMLTable as well.
    Many of those examples can be found on the {forum:id=34} forum or [Marco&apos;s blog|http://www.liberidu.com/blog/]. A few parsing examples that I've done can be seen at {message:id=3610259}, make sure to also follow the link I put in there to a previous example before that.

  • No default attributes while Parsing XML document

    Hellow.
    I have such a problem:
    I have XML document that uses XSD-schema.
    In XSD-schema there is element that have two atributes:
    <xsd:complexType name = "El1">
          <xsd:attribute name = "atr1" xsd:default = "0" type = "xsd:boolean"/>
          <xsd:attribute name = "atr2" default = "0" type = "xsd:boolean"/>
    </xsd:complexType>And in XML document I write:
    <El1 atr1 = "1"/>According to the XSD-schema parser must add to El1 second attribute "atr2" with its default value because it has default value. But when I do such a code:
    factory = DocumentBuilderFactory.newInstance();
    builder = factory.newDocumentBuilder();
    doc = builder.parse(new File("file1.xml"));
    Element pEl;
    pEl = doc.getDocumentElement()
    NamedNodeMap Attribs = pEl.getAttributes();In the list of attributes "Attribs" - there is no attribute "attr1"!!!
    What I have to do???

    Hello All
    I am new to this parsing world. I have a doubt. I have an XML like
    <xml>
    <platform name = "windows">
    <computer>
    <hostname> hostname1 </hostname>
    <IPAddress>127.0.3.03 </IPAddress>
    </computer>
    <computer>
    <hostname> hostname2 </hostname>
    <IPAddress>127.0.3.04 </IPAddress>
    </computer>
    </platform>
    <platform name = "unix">
    <computer>
    <hostname> hostname6 </hostname>
    <IPAddress>127.0.3.08 </IPAddress>
    </computer>
    <computer>
    <hostname> hostname7 </hostname>
    <IPAddress>127.0.3.09 </IPAddress>
    </computer>
    </platform>
    </xml>
    If i want to get details about individual computer under each platform as a string how do i do that?
    Which parser would be ideal to be used DOM or SAX.

  • Parse xml document with xpath

    I would like to parse an xml document using xpath, see:
    http://www.onjava.com/pub/a/onjava/2005/01/12/xpath.html
    however, in the documentation (in the link above), it states that I need J2SE 5.0.
    Currently, I have:
    $ java -version
    java version "1.5.0_11"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
    Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode, sharing)
    Does that mean that I really have to install J2SE 5.0 in order to use J2SE 5.0's XPath support? Does anybody know anything about getting started with XPath, and whether I can just use my existing version of Java? I've never used XPath.
    For more documentation, one can view:
    http://www.w3.org/TR/xpath20/
    Thank you.

    I have copied the code for the xpath tutorial on
    http://www.onjava.com/pub/a/onjava/2005/01/12/xpath.html
    exactly as it is on the tutorial, and imported the correct jars (I think).
    But still my code is giving lots of errors!
    Granted its my first shot but anyway here's the code and the errors...
    package test;
    import org.jdom.xpath.*;
    import java.io.*;
    import javax.xml.xpath.*;
    public class XPath {
         public static void main (String [] args){
              XPathFactory factory = XPathFactory.newInstance();
              XPath xPath=factory.newXPath();
              XPathExpression  xPathExpression=xPath.compile("/catalog/journal/article[@date='January-2004']/title");
              File xmlDocument = new File("/home/myrmen/workspace/Testing/test/catalog.xml");     
              //FileInputStream fis = new FileInputStream(xmldocument); 
              InputSource inputSource = new InputSource(new FileInputStream(xmlDocument));
              String title = xPathExpression.evaluate(inputSource);
              String publisher = xPath.evaluate("/catalog/journal/@publisher", inputSource);
              String expression="/catalog/journal/article";
              NodeSet nodes = (NodeSet) xPath.evaluate(expression, inputSource, XPathConstants.NODESET);
              NodeList nodeList=(NodeList)nodes;
              SAXBuilder saxBuilder = new SAXBuilder("org.apache.xerces.parsers.SAXParser");
              org.jdom.Document jdomDocument = saxBuilder.build(xmlDocument);
              org.jdom.Attribute levelNode = (org.jdom.Attribute)(XPath.selectSingleNode(jdomDocument,"/catalog//journal[@title='JavaTechnology']" + "//article[@date='January-2004']/@level"));
              levelNode.setValue("Intermediate");
              org.jdom.Element titleNode = (org.jdom.Element) XPath.selectSingleNode( jdomDocument,"/catalog//journal//article[@date='January-2004']/title");
              titleNode.setText("Service Oriented Architecture Frameworks");
              java.util.List nodeList = XPath.selectNodes(jdomDocument,"/catalog//journal[@title='Java Technology']//article");
              Iterator iter=nodeList.iterator();
              while(iter.hasNext()) {
                   org.jdom.Element element = (org.jdom.Element) iter.next();
                   element.setAttribute("section", "Java Technology");
              XPath xpath = XPath.newInstance("/catalog//journal:journal//article/@journal:level");
              xpath.addNamespace("journal", "http://www.w3.org/2001/XMLSchema-Instance");
              levelNode = (org.jdom.Attribute) xpath.selectSingleNode(jdomDocument);
              levelNode.setValue("Advanced");
    Exception in thread "main" java.lang.Error: Unresolved compilation problems:
         Type mismatch: cannot convert from XPath to XPath
         The method compile(String) is undefined for the type XPath
         InputSource cannot be resolved to a type
         InputSource cannot be resolved to a type
         NodeSet cannot be resolved to a type
         NodeSet cannot be resolved to a type
         NodeList cannot be resolved to a type
         NodeList cannot be resolved to a type
         SAXBuilder cannot be resolved to a type
         SAXBuilder cannot be resolved to a type
         The method selectSingleNode(Document, String) is undefined for the type XPath
         The method selectSingleNode(Document, String) is undefined for the type XPath
         Duplicate local variable nodeList
         The method selectNodes(Document, String) is undefined for the type XPath
         Iterator cannot be resolved to a type
         The method newInstance(String) is undefined for the type XPath
         The method addNamespace(String, String) is undefined for the type XPath
         The method selectSingleNode(Document) is undefined for the type XPath
         at test.XPath.main(XPath.java:12)

  • How Save XML Document in a Destination Table

    Hi
    How Save a XML Document Information in Data Table.
    for Example
    Create Table MDat (Id Number(6), Description Varchar2(50))
    XML Document
    <Data>
    <ROW NUMROW="1" ID="1" Description="Dat 01" /ROW>
    <ROW NUMROW="2" ID="5" Description="Dat 05" /ROW>
    </DATA>
    I Need insert into Tabla MDAT XML Document Information, This XML Document exist in Server Directory.
    Thanks
    PS: I Have a Steve Muench Book (Building Oracle XML Aplications.

    huh? Perhaps READING Steven's book might help you in this matter :) For smallish files you can probably use putXML (e.g., p 467) or if you have a more complex or larger then you need to work with XMLLoader (also in the book (p. 534) as well as online somewhere).
    Mike
    null

  • Using parser to parse xml document

    Hi all:
    I have a xml document which has a root element and the a list of elements(same type) underneath it.
    My question is:
    Is there a restriction on the number of elements(same type) that you can extract from the Document?
    Thanks.
    Rino

    If you use DOM of JDOM, you will have a problem when you run out of system memory.
    If you use SAX, the parser will throw events with the required data for the current node (element, data, attribute). Once the event has been processed, the data is out of scope (unless you still hold a reference to it).
    If you use SAX, you are able to process each node without keeping the data from that node any longer than you like. Unless you have to have the entire document available, I would suggest using SAX.

  • Parse XML document based on the criteria

    Hi,
    I'm trying to parse an xml document using sax parser. I don't want to parse whole xml document. I want to parse based on the start element which I specify and parsing should stop based on the end element which i specified. I don't know how to restrict while parsing . The start element and end element will be varying ? Can somebody help out in resolving this problem.
    thanks in advance

    Don't look at it that way. The SAX parser will give you the document in pieces; just ignore the pieces you aren't interested in.

Maybe you are looking for

  • Getting error while deploying the Enterprise application

    iam getting the Error while i deploying enterprise application which contain the EJB  methods. that Error iam getting like follow. java.rmi.RemoteException: Cannot deploy application sap.com/Energy_eap.. Reason: Incorrect application sap.com/Energy_e

  • Field for Vendor Invoice status

    Hi guys, We have to fetch the vendor invoice status for the given invoice. I checked with the table RBKP there the field RBSTAT shows the status, but it shows only status like (PARK, POSTED etc) but the requirement is to get the status like (PAID, VO

  • Link to forums either in help file or application (kind of silly request)

    Hello! So - I wanted to come to these forums and make a feature request about script locking, but it took me a long time to get back to the forum because I couldn't find a link anywhere.  Could you add one to the Help menu perhaps (instead of just do

  • Writing non-latin Character to Log file from Java application

    Hi Everyone, I'm encountering a very strange localization issue. I'm executing the following code from a J2EE application (although the behavior is replicated exactly from a Java console application): File testFile = new File("D:\\Temp\\blah.txt"); t

  • Broker Fee calcaulation

    Hi: When we export a product, we need to pay broker commission nased on sales order value. I have a carrier as well as broker on shipment document. When I create shipment cost document, Is it possible to create a condition for  a broker (% commission