How use forEach tag in xml tag library

Hi,
Can u please explain the procedure for using forEach tag for displaying the parsed xml tags?
This is the code snippet
<%@ page contentType="text/html" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jstl/xml" %>
<html>
<body>
     <c:import url="\books.xml" var="url" />
     <x:parse xml="${url}" var="doc" />
          <x:forEach var="n" select="${doc}/books/book">
               <x:out select="${n}/title"/>
               <x:out select="${n}/author" />
     </x:forEach>
</body>
</html>
but I got the fallowing error.
java.lang.NoClassDefFoundError: org/saxpath/SAXPathException
     at org.apache.taglibs.standard.tag.common.xml.ForEachTag.prepare(ForEachTag.java:51)
     at javax.servlet.jsp.jstl.core.LoopTagSupport.doStartTag(LoopTagSupport.java:262)
     at jsp_servlet.__index._jspService(__index.java:197)
     at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
     at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:971)
     at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:402)
     at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
     at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6350)
     at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
     at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
     at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3635)
     at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585)
     at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
     at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)

Just the same way as you do in JSP. Since JSF 1.2 you can use unified EL #{ } in c:forEach.
You can also use Tomahawk's [t:dataList|http://myfaces.apache.org/tomahawk-project/tomahawk12/tagdoc/t_dataList.html] by the way. It is more efficient.

Similar Messages

  • How to use Euro symbol in xml tags?

    How to use Euro symbol in xml tags?

    What do you mean by "in xml tags"? Can you post a three-line XML snippet showing what you hope to achieve?

  • How to read value within XML Tag data using IO Stream in Java

    We have xml data into a Stream and we need to extract values again into a Stream from the particular XML tag <Data> inside the Stream. PFB the sample XML which will be contained inside the stream and can someone help us to hint the java code for this. We require it using the IO API only and we need to look <DATA> for the begining of the stream and </DATA> as the end of the stream.
    Please note that input is stream and output require also is a stream.
    <?xml version = "1.0" encoding="UTF-8" ?>
    <GenericDataEnvelope>
    <DataFormat>PlainText</DataFormat>
    <Name>1111</Name>
    <Security>NA</Security>
    <senderName>abc</senderName>
    <Protocol>HTTP</Protocol>
    <Data>
    SElQRlhDVElQRlBCTktERUZGMDYxMDAyMDc0MzUyMDAwMTA2MTAwMjA3NDM1MlRDSEFTVVMzMzAw
    MDAwMDAwMDAwMTc4LDEyMDAwMTc4MTIKezQ6TVQxMDM6CjoyMDowMDYwMDQ5MjQxMDA2NzcwCjoy
    M0I6Q1JFRAo6MjNFOlNEVkEKOjMyQTowNjEwMDVDQUQwLDAxCjozM0I6RVVSMCwwMQo6MzY6MSwz
    TNzcwQU5WLVJFTlRFIE9DVCAwNgowLDAxLzEsMTcxOQo6NzFBOlNIQQo6NzI6L1JFQy84NDM2MTU3
    MTA2Ci19ClRJUEYK
    </Data>
    <DataType>INVOICE</DataType>
    </GenericDataEnvelope>

    The example you've showed is valid and it is also text.
    Think seriously about this ... for example, do you have a rule that says </DATA> can't appear in the binary data?
    But in any case I can't see the problem. If you want to use IO classes directly, just read lines until you see <DATA>, then read data until it ends with </DATA>, and remove that.
    But I would certainly use SAX myself until proven otherwise that it won't work..

  • How to read content between xml tags?

    is there any way to read the content between xml tag

    > is there any way to read the content between xml tag
    Yes. Are you having some sort of problem? If so, please be a little more explicit about what you're doing, what you expect to happen, and what you actually observe.
    Please post a short, concise, executable example of what you're trying to do. Don't post the actual code you are using (I can't emphasize this strongly enough). Just write a small example that demonstrates the problem, and only that. Wrap the code in a class and give it a main method that runs it - if we can just copy and paste the code into a text file, compile it and run it without any changes, then we can be sure that we haven't made incorrect assumptions about how you are using it.
    Post your code between [code] and [/code] tags. Cut and paste the code, rather than re-typing it (re-typing often introduces subtle errors that make your problem difficult to troubleshoot). Please preview your post when posting code.
    Please assume that we only have the core API. We have no idea what SomeCustomClass is, and neither does our collective compiler.
    If you have an error message, post the exact, complete error along with a full stack trace, if possible. Make sure you're not swallowing any Exceptions.
    Help us help you solve your problem.
    ~

  • How use bean of array with tag "jsp:useBean"??

    hi,all
    a bean of array put request with a servlet and forward a jsp page,this jsp use "jsp:useBean" of tag get the bean of array.
    how do for jsp:useBean of tag??
    thx.....

    You can't use an array directly in a jsppage. first u have to write the line <useBean /> through which you can access youtr class
    <jsp:useBean id="email" class="Pack.Email" scope="session" />
    after writing this line you have your class in your hand, you can think of "email" as it is a class object of Email class which is a Bean...
    declare a private array in the Bean and then made method getArray() which will return an array ... then you can use your array in jsp....
    an example of using a class variable in JSp is given below
    public String[] getArray() // note method must be public
    return array;
    now in your jsp page you have to use that class with
    <jsp:useBean id="email" class="Pack.Email" scope="session" />
    and cnow you can use array like this....
    <%
    String[] array=email.getArray();
    for (int i=0; i< array.length;i++ )
    out.println(array]);
    %>
    Does it solve your problem now ?

  • Html tag as xml tag value?

    Hi,
    Can I put a html tag as value to a xml tag? something like this
    <abc>
    <username>Uma</username>
          <displayTag>
                  <start><h1></start>
                  <end></h1></end>
          </displayTag>
    </abc>Please help.
    Thanks in advance.

    You can either use > and < for < and > to get something that appears to be an html tag, or you can use a CDATA section.
    It partly depends on what you plan to do with that content.
    Dave Patterson

  • Q: How to access and modify xml tags using Java

    I have an xml based document that i need to access and change. For example, the code
    <section id="section1">
    <div>
    <xforms:group id="id1">
    <xforms:label id="label1">
    <l style="font-size:16pt"> something </l>
    </xforms:label>
    </xforms:group>
    </div>
    </section>
    Working with Java I need to access all the tags, select some of them that are relevant to the current device and remade the document. I thought I would read the file character by character identifying the different labels and building a tree, storing in the tree nodes the relevant information as some kind of attributes (for example, in the case of the <xforms:group id="id1"> I would name the node "xforms:group" and create an "id" attribute with value "id1"). I'm not sure if that is the most efficient way of accessing the problem (computational power might be an issue), and would appreciate some help on the subject.
    Thanks,

    this may help you..
    this is a little util i made to help me read/write files.
    using this, you are only one step away from your solutions, you only need to figure out the regex you need to run on the text of the file to make it become what you need it to become.
    though if you use non-standard encoding, you might not want to use this code..
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.Arrays;
    public class ASCIIFile {
         private File file;
         private StringBuilder builder;
         public ASCIIFile(String path) throws IOException{
              file = new File(path);
              openFile();
         public ASCIIFile(File file) throws IOException{
              this.file = file;
              openFile();
         public void setNewFileName(String fileName){
              file = new File(file.getAbsolutePath(), fileName);
         public void setNewFilePath(String filePath){
              file = new File(filePath, file.getName());
         private void openFile() throws IOException{
              if(!file.exists()) file.createNewFile();
              BufferedReader read = new BufferedReader(new FileReader(file));
              String line = read.readLine();
              builder = new StringBuilder();
              while(line != null){
                   builder.append(line);
                   builder.append("\n");
                   line = read.readLine();
              read.close();
         public String getContents(){
              return builder.toString();
         public StringBuilder getStringBuilder(){
              return builder;
         public void setStringBuilder(StringBuilder b) throws IOException{
              setContents(b.toString());
         public void setContents(String contents) throws IOException{
              FileWriter writer = new FileWriter(file);
              writer.write(contents);
              writer.flush();
              writer.close();
              builder = new StringBuilder(contents);
         public static File[] getAllFilesUnderDir(String fullpath, boolean recursive) {
              ArrayList queue = new ArrayList(10);
              ArrayList matched = new ArrayList();
              File root = new File(fullpath);
              File[] files = root.listFiles();
              if (files == null || files.length == 0) {
                   return new File[] {};
              queue.addAll(Arrays.asList(files));
              for (int j = 0; j < queue.size(); j++) {
                   File child = (File) queue.get(j);
                   if (child.isDirectory() && recursive) {
                        files = child.listFiles();
                        if (files != null) {
                             queue.addAll(Arrays.asList(files));
                   } else { // child is file
                        matched.add(child);
              return (matched.size() > 0)?((File[]) matched.toArray(new File[] {})):(new File[] {});
    }

  • Spec oversight? Using dynamic-attributes in XML tag files

    I have a couple of tagfiles that generate form elements with specific conventions for the 'name' and 'value' attribute. Basically, a data binding framework.
    Dynamic attributes are useful because you can delegate all the usual html attributes to the generated HTML form element: SELECT, INPUT, id, class etc.
    The usual way to do this is to concatenate all the "pass-through" attributes to a string, and append this string to the element generated:
    <input type="hidden" name="foo" ${dynattrs}/>I'm wondering how to do this in a tagfile in XML format (mytag.tagx), since the XML format forbids syntax like in the example above.
    jsp:attribute won't help much, if it's nested inside a c:forEach: it won't apply to the right element.

    Ran into the same problem with 'optional attributes'. (see post "JSP 2.0 Tag files outputting elements with conditional attributes" http://forum.java.sun.com/thread.jspa?forumID=45&threadID=681033)
    Found a solution that is not very elegant but does work and saves you the trouble of reverting to Java Tags. Consider the following tag-file that outputs an html input-tag with conditional attributes:
    <?xml version="1.0" encoding="utf-8"?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2"
         xmlns:c="http://java.sun.com/jsp/jstl/core">
         <jsp:directive.attribute name="name" required="true" type="java.lang.String"/>
         <jsp:directive.attribute name="id" required="false" type="java.lang.String"/>
         <jsp:directive.attribute name="value" required="false" type="java.lang.String"/>
         <jsp:directive.attribute name="disabled" required="false" type="java.lang.Boolean"/>
         <jsp:directive.attribute name="hint" required="false" type="java.lang.String"/>
         <jsp:directive.attribute name="cssClass" required="false" type="java.lang.String"/>
         <jsp:text><![CDATA[<input type="text" name="]]><c:out value="${name}"/><![CDATA["]]></jsp:text>
         <c:if test="${!empty id}"><![CDATA[ id="]]><c:out value="${id}"/><![CDATA["]]></c:if>
         <c:if test="${!empty cssClass}"><![CDATA[ class="]]><c:out value="${disabled?(cssClass + '-disabled'):cssClass}"/><![CDATA["]]></c:if>
         <c:if test="${disabled}"><![CDATA[ disabled="disabled"]]></c:if>
         <c:choose>
              <c:when test="${!empty value}"><![CDATA[ value="]]><c:out value="${value}"/><![CDATA["]]></c:when>
              <c:when test="${!empty hint}"><![CDATA[ value="]]><c:out value="${hint}"/><![CDATA[" onfocus="if(this.value==']]><c:out value="${hint}"/><![CDATA[')this.value='';"]]></c:when>
         </c:choose>
         <jsp:text><![CDATA[/>]]></jsp:text>
    </jsp:root>In answer to your question: Yes, it looks like an oversight. Using the jsp:attribute tag in a c:forEach doesn't work because the attribute is then applied to the forEach tag. You would have to put the attribute-tag inside a jsp:body tag (inside the forEach). Then it would apply not to the forEach tag but to the tag enclosing the forEach. However, this doesn't work either, or at least it doesn't work in Tomcat 5.5. Could be a bug though, JSP 2.0 is still very buggy (for instance, using a tagfile inside another tagfile from the same taglib doesn't seem to work either...)
    Anyway, if you ever find a good solution please let me know by posting to this topic!
    TIA

  • How to Find the XML Tag in indesign

    HI!!<br /><br />We are working with XML work flow in indesign. In indesign how could we find the XML Tag in indesign.<br /><br />Example::<br />In the Below list we could have to find the xml tag <chapter> in story editor or in the main text frame in indesign using find option. Kindely sent if any Plugins is available.<br /><br />For exmaple:<br />************<br /><book><br /> <part><br /> <chapter><br />  <head><br />   <para><br />    <bold><br /><br />Thanks,<br />C.K.Venkatesan

    I imported the xml file in vb.net. now i want to find the number of pages and no. of elements. i found out it. but i was not able to find which elements are placed in which page. i want that information. plz kindly help. i am using vb.net. for eg. <ce:figure> placed in which page no., <ce:sections> placed in which page no., etc..,

  • How to Read XML tags....

    Hi guys...
    Can any one here tell me how to read the XML tag in PL/SQL.
    In table Enquiry there are following fields.
    Id          number
    Status          varchar2(5)
    Request          XML
    Reply          XML
    Error          varchar2(10)
    Now the following XML will be in request column from the requester.
    I have to get the,
    ->request which is in BODY tag,
    ->ID number which is in from tag (its the persons unique ID to check his BILL)
    Fetch the request from the database and updates it into the REPLY field with the same syntax.
    <message>
    <to> 123 </to>
    <from>789</from>
    <body> unbill </body>
    <messagenumber> 01 </messagenumber>
    </message>
    Can any one have the solution to this, how can I read the XML tags, process & again inserts as an XML.
    Thanks.

    Maybe something like this will be a pointer...
    SQL> CREATE TABLE t AS
      2  select 1 as id, 'C' as status, XMLTYPE('<message><to>123</to><from>789</from><body>unbill</body><messagenumber>01</messagenumber></message>') as request, XMLTYPE('<reply/>') as reply, 'NO ERROR' as error from dual
      3  ;
    Table created.
    SQL>
    SQL> SELECT * from t;
            ID S
    REQUEST
    REPLY
    ERROR
             1 C
    <message><to>123</to><from>789</from><body>unbill</body><messagenumber>01</messagenumber></message>
    <reply/>
    NO ERROR
    SQL>
    SQL> UPDATE t
      2  SET reply = updateXML(request,'/message/body/text()','bill')
      3  ;
    1 row updated.
    SQL>
    SQL> SELECT * from t;
            ID S
    REQUEST
    REPLY
    ERROR
             1 C
    <message><to>123</to><from>789</from><body>unbill</body><messagenumber>01</messagenumber></message>
    <message><to>123</to><from>789</from><body>bill</body><messagenumber>01</messagenumber></message>
    NO ERROR
    SQL>

  • Need help in extracting value from an xml tag.

    Hi ALL,
    Good Morning to all, i have problem in fetching a value from a xml tag. I have created a xml schema based on the schema i have created a xmltype table and inserted a value to the table. When i am trying to fetch a value from a particular tag i am unable to do so.. Kindly help me to solve this. Here by i am posting all the workings i have done...
    I am using the following client:
    SQL*Plus: Release 10.2.0.1.0 - Production on Mon Jan 31 11:44:59 2011
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    ////////////////////////////////// XML Schema ///////////////////////
    begin
    dbms_xmlschema.registerSchema(
    'http://www.oradev.com/chipsxml.xsd',
    '<schema xmlns="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.oradev.com/chipsxml.xsd"
    xmlns:samp="http://www.oradev.com/chipsxml.xsd"
    version="1.0">
    <element name="Field1">
    <complexType>
    <sequence>
         <element name="UTI">
              <complexType>
              <sequence>
              <element name = "U01" type = "string"/>
              <element name = "U02" type = "string"/>
              <element name = "U03" type = "string"/>
              <element name = "U03a" type = "string"/>
              <element name = "U03b" type = "string"/>          
              <element name = "U03c" type = "string"/>          
              <element name = "U04" type = "string"/>                    
              <element name = "U05" type = "string"/>                    
              </sequence>
              </complexType>
         </element>
    </sequence>
    </complexType>
    </element>
    </schema>',
    TRUE, TRUE, FALSE, FALSE);
    end;
    ////////////////////////// Table which has multiple Column //////////////////////////
    CREATE TABLE chipsxmltable1 (
    id number, XMLDATA XmlType)
    XMLTYPE XMLDATA STORE AS OBJECT RELATIONAL
    XMLSCHEMA "http://www.oradev.com/chipsxml.xsd"
    ELEMENT "Field1";
    ///////////////////////////////// Insert Query in chipsxmltable //////////////////////////
    INSERT INTO chipsxmltable VALUES(
    xmltype.createxml('<?xml version="1.0"?>
    <samp:Field1 xmlns:samp="http://www.oradev.com/chipsxml.xsd" >
    <UTI>
    <U01>No</U01>
    <U02>Y</U02>
    <U03>Y</U03>
    <U03a>Y</U03a>
    <U03b>Y</U03b>
    <U03c>Y</U03c>     
    <U04>Y</U04>
    <U05>Y</U05>          
    </UTI>
    </samp:Field1>'));
    To show the data as a field with structure:
    1. Query:
    Select * from chipsxmltable1;
    Output:
    ID XMLDATA
    1 <?xml version="1.0"?>
    <samp:Field1 xmlns:samp="http://www.oradev.com/chipsxml.xsd">
    <UTI>
    <U01>No</U01>
    <U02>No</U02>
    <U03>Y</U03>
    <U03a>Y</U03a>
    <U03b>Y</U03b>
    <U03c>Y</U03c>
    <U04>Y</U04>
    <U05>Y</U05>
    </UTI>
    </samp:Field1>
    2. Query: (Both the query displays the same Output)
         SELECT X.xmldata.getClobVal() "XMLDATA" FROM chipsxmltable1 X;
         select extract(XMLDATA, '/Field1').getstringval() "XMLDATA" from chipsxmltable1 x;
    Output:
    XMLDATA
    <?xml version="1.0"?>
    <samp:Field1 xmlns:samp="http://www.oradev.com/chipsxml.xsd">
    <UTI>
    <U01>No</U01>
    <U02>No</U02>
    <U03>Y</U03>
    <U03a>Y</U03a>
    <U03b>Y</U03b>
    <U03c>Y</U03c>
    <U04>Y</U04>
    <U05>Y</U05>
    </UTI>
    </samp:Field1>
    To show the data as a single string without structure using "getstringval()":
    3. Query
         select extract(XMLDATA, '//text()').getstringval() "CHIPS - XML" from chipsxmltable1 x;
    OUtput:
    CHIPS - XML
    NoNoYYYYYY
    To show the data as a single string without structure using "getclobval()":
    4.Query
         select extract(XMLDATA, '//text()').getClobVal() "CHIPS - XML" from chipsxmltable1 x;
    Output:
    CHIPS - XML
    NoNoYYYYYY
    To show the data in a particular tag with/Without structure (Which is not working) using "EXTRACT" function:
    6.Query:
         select extract(XMLDATA, '/Field1/text()').getstringval() "XMLDATA" from chipsxmltable1 x;
         select extract(XMLDATA, '/Field1/UTI').getstringval() "XMLDATA" from chipsxmltable1 x;
         select extract(XMLDATA, '/Field1/UTI/U01').getstringval() "XMLDATA" from chipsxmltable1 x;
         select extract(XMLDATA, '/Field1/UTI/U01/text()').getstringval() "XMLDATA" from chipsxmltable1 x;
    Output:
    CHIPS - XML
    The above queries are not fetching the value.
    To show the data in a particular tag with/Without structure (Which is not working) using "EXTRACTVALUE" function:
    7. Query:
         select extractValue(XMLDATA, '/Field1/UTI') "XMLDATA" from chipsxmltable1 x;
         select extractValue(XMLDATA, '/Field1/UTI/U01') "XMLDATA" from chipsxmltable1 x;
    Output:
    X
    The above queries are not fetching the value.
    My question is:
    How to fetch values from xml tag when the value are inserted through xml schema?
    Apologies if the description is not clear. Kindly let me know if further details are needed. Many thanks for your help.
    Very best regards,
    Godwin Jebakumar C.V.

    Hi,
    You need to declare the namespace of each element used in the XPath expression, like this :
    SQL> select extractvalue( XMLDATA
      2                     , '/samp:Field1/UTI/U01'
      3                     , 'xmlns:samp="http://www.oradev.com/chipsxml.xsd"' ) "XMLDATA"
      4  from chipsxmltable1 x
      5  ;
    XMLDATA
    No
    SQL> select extract( XMLDATA
      2                , '/samp:Field1/UTI'
      3                , 'xmlns:samp="http://www.oradev.com/chipsxml.xsd"'
      4                ).getstringval() "XMLDATA"
      5  from chipsxmltable1 x
      6  ;
    XMLDATA
    <UTI>
      <U01>No</U01>
      <U02>Y</U02>
      <U03>Y</U03>
      <U03a>Y</U03a>
      <U03b>Y</U03b>
      <U03c>Y</U03c>
      <U04>Y</U04>
      <U05>Y</U05>
    </UTI>
    Please see EXTRACT and EXTRACTVALUE documentation :
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions051.htm#i1006712
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions052.htm#SQLRF06173
    BTW, "XMLDATA" is a pseudo-column used by Oracle. I don't know if it'll ever cause any conflict but maybe you should rename your column.
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/pseudocolumns010.htm#SQLRF00256
    Regards.

  • Stripping off XML tags

    Hi,
    Can someone help me with providing some code on how to strip off the XML tags in an XML file like the following:
    <?xml version = '1.0'?>
    <!--<?xml-stylesheet type="text/xsl" href="XYZ.xsl"?> -->
    <ROWSET>
    <ROW num="1">
    <PRODUCT_NAME>ABC</PRODUCT_NAME_NAME>
    </ROW>
    <ROW num="2">
    All I want to get back is whatever in between <product_name>. Basically, all the tags with <..> I need to get rid off from this XML file.
    Does anybody know if I can use regular expressions in java? That way, would it be easier not to use parsers?
    Please provide me ideas, sources, examples, etc.
    Thanks in advance.

    I worked on the solution, but, it's coming up with a blank list.
    Any solution to resolve this!
    Here's the code:
    public class Test extends JFrame
         JList list;
         JScrollPane listContainer;
         public Test()
              setSize(300, 300);
              setVisible(true);
              setTitle("ProdList");
              initialize();
         // domParse();     // Getting error- how do i call this function?
         public void initialize()
              list = new JList(new DefaultListModel()); // Set the initial model
              listContainer = new JScrollPane(list);
              listContainer.setSize(new Dimension(200, 200));
              getContentPane().setLayout(new BorderLayout());
              getContentPane().add(listContainer, "Center");
              validate(); // Validate the screen
         // public void domParse(String url)
         public void domParse(String url)
              DocumentBuilder parser;
              DocumentBuilderFactory factory =
                        DocumentBuilderFactory.newInstance();
              try {
                        parser = factory.newDocumentBuilder();
                        Document doc = parser.parse(url);
              NodeList product_names = doc.getElementsByTagName("PRODUCT_NAME");
              if(product_names!=null)
              for(int i=0;i<product_names.getLength();++i)
                   // get all child nodes of a <product_name> - node
                   NodeList product_name_children=product_names.item(i).getChildNodes();
                   // and display contents of text nodes
              for(int j=0;j<product_name_children.getLength();++j)
                   Node node=product_name_children.item(j);
              //if(node.getNodeType()==Node.TEXT_NODE)
                   //System.out.println("element <"+product_names.item(i).getNodeName()+">'s text=["+node.getNodeValue()+"]");
              else
                   System.out.println("no element <PRODUCT_NAME> found");
              } catch (Exception e)
              // e.printStackTrace();
              static public void main(String[] args)
                   Test x=new Test();
                   x.domParse("Test.xml");

  • How to achive in this data in oracle using xml tag ?

    hi All ,
    i am using sql 3.1
    i have one question that how can i achieve this below XML tag using XML query. this below  whatever i am showing here data is one table . how can i achieve this things using XML tag like xml forest or whatever may be
    please help me .
    ---code
    <Metadata>
    <Dept Deptno="10">
      <Name>Administration</Name>
      <Location>Seattle</Location>
      <Employees>
       <Emp empid="200">
        <FirstName>Jennifer</FirstName>
        <LastName>Whalen</LastName>
       </Emp>
      </Employees>
    </Dept>
    <Dept Deptno="20">
      <Name>Marketing</Name>
      <Location>Toronto</Location>
      <Employees>
       <Emp empid="201">
        <FirstName>Michael</FirstName>
        <LastName>Hartstein</LastName>
       </Emp>
       <Emp empid="202">
        <FirstName>Pat</FirstName>
        <LastName>Fay</LastName>
       </Emp>
      </Employees>
    </Dept>
    </metadata>
    Thanks
    Damby

    please reply

  • How can we get  tag of XML file using SAX

    Hi ,
    I'm parsing one SAX parser , I'have almost done this parsing. i have faced problem for one case, i'e how can we get tag from XML file using SAX parser?
    XML file is
    <DFProperties>
    <AccessType>
    <Get/>
    </AccessType> <Description>
    gdhhd
    </Description>
    <DFFormat>
    <chr/>
    </DFFormat>
    <Scope>
    <Permanent/>
    </Scope>
    <DFTitle>gsgd</DFTitle>
    <DFType>
    <MIME>text/plain</MIME>
    </DFType>
    </DFProperties>
    I want out like GET and Permanent... means this one tag which is present inside of another tag.
    Handler class like
    public void startElement(String namespaceURI, String localName,
                   String qName, Attributes atts) throws SAXException {
    if(_ACCESSTYPE.equals(localName)){
                   accessTypeElement=ACCESSTYPE;
    public void characters(char[] ch, int start, int length)
                   throws SAXException {
    if (_ACCESSTYPE.equals(_accessTypeElement)) {
                   String strValue = new String(ch, start, length);
                   System.out.println("Accestype-----------------------------> " + strValue);
                   //System.out.println(" " + strValue);
    public void endElement(String namespaceURI, String localName, String qName)
                   throws SAXException {
    if (_ACCESSTYPE.equals(localName)) {
                   _accessTypeElement = "";
    . please any body help me

    Hi ,
    I have one problem,Please help me.
    1. How can I'll identify where exactly my Node is ended,means how how can we find corresponding nodename? in partcular place
    <Node> .............starttag1
    <NodeName>Test</NodeName>
    <Node>................starttag2
    <nodeName>test1</NodeName>
    </Node>..................endtag2
    <Node>.....................starttag3
    <NodeName><NodeName>
    <Node> .........................starttag4
    <NodeName>test4</NodeName>
    </Node>.......enddtag4
    </Node>...........end tag3
    </Node>............endtag1
    my code is below
    private final String _NODENAME = "NodeName";
    private final String _NODE = "Node";
    private String _nodeElement = "";
         private String _NodeNameElement = "";
    public void startElement(String namespaceURI, String localName,
                   String qName, Attributes atts) throws SAXException {
    if (_NODENAME.equals(localName)) {
                   NodeNameElement = NODENAME;
    if(_NODE.equals(localName)){
         System.out.println("start");
         if (_NODENAME.equals(localName)) {
                   NodeNameElement = NODENAME;
    public void characters(char[] ch, int start, int length)
                   throws SAXException {
    if (_NODENAME.equals(_NodeNameElement)) {
                   String strValue = new String(ch, start, length);
                   String sttt=strValue;
                   System.out.println("NODENAME: ************* " + strValue);
    if(_NODE.equals(_nodeElement)){
                   if (_NODENAME.equals(_NodeNameElement)) {
                        String strValue = new String(ch, start, length);
                        String sttt=strValue;
                        System.out.println("nodevalue********** " + strValue);
    public void endElement(String namespaceURI, String localName, String qName)
                   throws SAXException {
    if (_NODENAME.equals(localName)) {
                   _NodeNameElement = "";
    if(_NODE.equals(localName)){
                   System.out.println("NODENAME: %%%%%%%%%");
    please help me. How can I figure node ending for particular nodename

  • How to? regarding adding xml parent tag in generated xml script using C# scripting

    Hi All,
    I have a set of transformations, which will generate xml data by reading rows from database
    here is my data flow https://social.msdn.microsoft.com/Forums/getfile/606619
    <Customer> 
    <CustomerId>1</CustomerId> 
    <Name></Name> 
    <Title></Title> 
    <Phone>1 (11) 500 555-0162</Phone> 
    <Gender>F</Gender> 
    <MaritalStatus>S</MaritalStatus> 
    <YearlyIncome>70000</YearlyIncome> 
    <BirthDate>15-02-1968 12:00:00</BirthDate> 
    <EmailAddress>[email protected]</EmailAddress> 
    <CustomerKey>11003</CustomerKey> 
    </Customer> 
    <Customer> 
    <CustomerId>2</CustomerId> 
    <Name></Name> 
    <Title></Title> 
    <Phone>1 (11) 500 555-0131</Phone> 
    <Gender>F</Gender> 
    <MaritalStatus>S</MaritalStatus> 
    <YearlyIncome>80000</YearlyIncome> 
    <BirthDate>08-08-1968 12:00:00</BirthDate> 
    <EmailAddress>[email protected]</EmailAddress> 
    <CustomerKey>11004</CustomerKey> 
    </Customer> 
    my problem is I am not able to add <?xml version="1.0" encoding="UTF-8"?> (xml tag) to output folder, which should be just at the beginning of xml file. 
    I am a beginner in SSIS, any help/hints will be appreciated.
    Regards,
    Mateen

    Why not do it in t-sql?
    http://visakhm.blogspot.in/2014/05/t-sql-tips-fun-with-for-xml-path.html
    http://visakhm.blogspot.in/2013/12/generating-nested-xml-structures-with.html
    If you want to do it in SSIS use this
    http://bicortex.com/how-to-create-an-xml-file-using-ssis-and-ms-sql-server/
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

Maybe you are looking for