Home Discussion Discuss: To Count XML Element

  • how to obtain element nameRanov October 24, 2011 at 10:01 AM

    Hi, thanks for your example. but i found some problem to obtain the result, below is my xml sample. <?xml version="1.0" encoding="UTF-8" standalone="no"?> <company> <staff id="1"> <firstname>yong</firstname> <lastname>mook kim</lastname> <nickname>mkyong</nickname> <salary>2000000</salary> <age>29</age> </staff> <staff id="2"> <firstname>low</firstname> <lastname>yin fong</lastname> <nickname>fong fong</nickname> <salary>1000000</salary> </staff> <staff id="3"> <firstname>Ali</firstname> <lastname>Baba</lastname> <nickname>Alibaba</nickname> <salary>199000</salary> <age>40</age> </staff> <manager id="1"> <firstname>Ranov</firstname> <lastname>Baba</lastname> </manager> <manager id="2"> <firstname>Rambo</firstname> <lastname>Baba</lastname> </manager> </company> My objective is to obtain: 1. All Element name inside the "company", in this case are "staff" & "manager" 2. Total Element inside the "company", which the result is 2 ("staff" & "manager"). Thanks for your help.

Post your Comment



Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Related Articles
XML Tutorials

To Count XML Element
To Count XML Element      ... helps to count the XML element. It takes a xml file (as a string ) at the console.... After parsing the XML document it asks for element name which have to count 

XML Tutorials

To Count The Elements in a XML File
To Count The Elements in a XML File       In this section, you will learn to count the element... the given XML document. It asks the element name and counts its occurence 

Programming Tutorials

Java xml count occurrence of elements
Java xml count occurrence of elements Java provides xml parsers to read, update, create and manipulate an XML document in a standard way. You have used xml... of each element in an XML document using SAX Parser and display them. The document 

XML Tutorials

Searching an Element in the given XML Document
Searching an Element in the given XML Document  ... asks for a  xml element name that have to be searched in the XML document... element  in XML document. If it counts to '0' that means element doesn't found 

XML Questions

XML root element
XML root element  Hi..... please tell me about that Can a root element type be explicitly declared in the DTD? Thanks 

XML Questions

XML - XML
XML  Write a program using SAX that will count the number of occurrences of each element type in an XML document and display them. The document file...)); System.out.print("Enter XML file name:"); String xmlFile = bf.readLine 

JDBC Questions

persistence xml class element
persistence xml class element  Hi, How to define class element in persistence.xml file. Thanks   Hi, You can use the .... tag. Here is the example: <class>net.roseindia.model.Product</class> Read more 

XML Tutorials

XML Count Elements
XML Count Elements      ...; that are used in your XML document using the SAX parser.  Description of program: Developing a java program, you need a XML well-formed document. When you run 

XML Questions

XML in java - XML
XML in java  Write a program using SAX that will count the number of occurrences of each element type in an XML document and display them... there are two or more command-line arguments, the program should count 

XML Questions

get element through attribute - XML
get element through attribute  hi,i need a function that gets(nodename and the attributevalue)and returns the node my file look like... link: http://www.roseindia.net/xml/ Hope that it will be helpful for you 

XML Tutorials

Remove Element from XML Document
Remove Element from XML Document     ... a given  XML document. Whenever you remove the xml element from the xml document the data are also lost from the xml element. Description of program: This program 

XML Tutorials

Getting The XML Root Element
Getting The XML Root Element     ... a  root element from the XML document.  The JAXP (Java APIs for XML... a DocumentBuilderFactory. After parsing the XML document you get  the node element using 

XML Questions

xml
xml  what is name space,xml scema give an example for each   XML Namespaces provide a method to avoid element name conflicts.They are used.... They are defined in a W3C recommendation.1 An XML instance may contain element 

XML

Example for Finding the Root Element in the XML File
Example for Finding the Root Element in the XML File In this tutorial, we will discuss about how to find the Root Element in the XML file. The XML DOM views... Root Element. First we create an XML file order.xml. The java and xml file 

Programming Tutorials

JDOM Element Example, How to get text of element of xml file.
JDOM Element Example, How to get text of element of xml file. In this tutorial, we will see how to get text value of an element from xml file by using JDOM toolkit. JDOM is a library used for manipulating xml file 

Programming Tutorials

JDOM Element Example, How to set attribute of xml element in java.
JDOM Element Example, How to set attribute of xml element in java. In this tutorial, we will see how to set attribute of xml element in java with the help..., and serializing XML documents. In this example, we will use some methods. DOMBuilder 

Programming Tutorials

JDOM Element Example, How to remove attribute of xml element in java.
JDOM Element Example, How to remove attribute of xml element in java. In this tutorial, we will see how to remove attribute of xml element in java with the help of JDOM library. It is a java tool kit for xml parsing. With the help 

XML Tutorials

Java DOM Tutorial
the standard SAX, DOM and XSLTs.    To Count XML Element... In this section, you will learn to count the element in XML document using... element from the XML document.  The JAXP (Java APIs for XML 

Programming Tutorials

JDOM Element example, How to get root element of xml file.
JDOM Element example, How to get root element of xml file. In this tutorial, we will see how to get root element of xml file. Code. Student.xml... [Element: <Student/>] Download this code 

Programming Tutorials

JDOM Element Example, How to get attribute value of xml element.
JDOM Element Example, How to get attribute value of xml element. In this tutorial, we will see how to get attribute value of xml element.. Element ... of given element. Code. Student.xml < 

XML Questions

java code - XML
java code  Write a program using SAX that will count the number of occurrences of each element type in an XML document and display them. The document file to be processed should be identified by the first command-line argument 

XML Tutorials

Cloning a XML Element
Cloning a XML Element      ... of any element of the specified XML file. For creating a DOM object ,  you... element at the specified position. Here is the XML File 

Java Interview Questions

Insert element into an existing xml file - Java Interview Questions
Insert element into an existing xml file  Dear all, how can i insert elements into an existing xml file? now when i am going to insert new elements... the example code at http://www.roseindia.net/xml/dom/xml-tutorial.shtml Post your 

XML Questions

xml - XML
xml  hi convert xml file to xml string in java ,after getting the xml string result and how to load xml string result? this my problem pls help..."); FileOutputStream output = new FileOutputStream("new.xml"); ReadXML xml = new 

XML Questions

Add a root element
Add a root element  i have one doubt, This is my current xml doc. ? But I want add a tag at first and last line of a xml by using JDOM(SAX Builder). Like  

XML Tutorials

Overview of element types
Overview of element types Schema defines the building blocks of an xml document so is very important to identify the type of the element. The element can be of simple type or complex type. Simple type does not contain elements 

Java Interview Questions

Insert element into an existing xml file - Java Interview Questions
Insert element into an existing xml file  thanks for the reply , I... a new root node "company" and then other elements, but i want the element...(); Element rootElement = document.createElement(root); //getDocumentElement 

Programming Tutorials

JDOM Attribute Example, How to add a list of attribute at a xml file element.
In this tutorial, we will see how to add a list of attribute to a xml file element...; attribute, which we want to add to xml element. The add() method ofArrayList add...) of Element class add attribute list at xml element. Code: book.xml 

PHP Tutorial

PHP Array Count Values
PHP Array Count Values  Sometimes  we need to count the number of values, i.e. total number of appearance of an element, in an array. PHP provides array_count_values() function to count the number of variables.  General 

Programming Tutorials

JDOM Element Example, How to remove child of an element from xml file in java.
JDOM Element Example, How to remove child of an element from xml file in java. In this tutorial, we will see how to remove child of an element from xml file... child    element of given name from existing xml file 

DMCA.com