aspose file tools
The moose likes Java in General and the fly likes reading xml file dynamically Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "reading xml file dynamically" Watch "reading xml file dynamically" New topic
Author

reading xml file dynamically

ash chowdary
Greenhorn

Joined: Apr 23, 2009
Posts: 16
hi,

i need to read a dynamic xml file from java code.. i have googled it but got only code for static xml parsing...can any one help in this regard...thanking you in advance.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35247
    
    7
Can you tell us where you see the difference between static and dynamic XML parsing is? Those are not terms that are commonly used.


Android appsImageJ pluginsJava web charts
ash chowdary
Greenhorn

Joined: Apr 23, 2009
Posts: 16
dynamic in the sense that, we will be getting an xml file,in which we don't know the nodes of that file except root node.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35247
    
    7
What are the operations that you need to perform on the XML?
ash chowdary
Greenhorn

Joined: Apr 23, 2009
Posts: 16
need to read all nodes and respective values.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35247
    
    7
Any API can do that: SAX, DOM, JDOM, XOM, ...
salvin francis
Ranch Hand

Joined: Jan 12, 2009
Posts: 915

hi,
All code online would be according to your defination, "static"

This is because usually a parser has an idea about the grammar
The apis mentioned will allow you to access the elements of an xml file

so say, you have the following:



and :


When you parse this with SAX,
you will come across document start eg: root
and for every tag, you will read the element start eg: name/userId
then you will read the chars within it eg: "salvin" / "java"
Now its up to you to write logic for them.
Without logic, its only known that A contains B.


My Website: [Salvin.in] Cool your mind:[Salvin.in/painting] My Sally:[Salvin.in/sally]
salvin francis
Ranch Hand

Joined: Jan 12, 2009
Posts: 915

also note that the example I have written is "flat" and usually xml contains nested data within tags...



So here, your code should expect that "site" is a parent for a series of elements including "name","desc","url"
also note the attributes "isMultiline" and "openInNewWindow"

what would you expect the code to do in the given xml example ?
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: reading xml file dynamically
 
Similar Threads
How to put xml heading in Jibx generated xml file
XML Parser
Generic XML parsing
how to read an XML file in java?
Why File name is becoming null in action class ?