File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes Representing an xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Representing an xml" Watch "Representing an xml" New topic

Representing an xml

Shreya Menon
Ranch Hand

Joined: Jul 31, 2001
Posts: 285
I have an XML file that looks like this
<?xml version="1.0"?>
<FIELDS CUST_ID="4" NAME="Customer" #SHAPE#="[Geometry]" #ID#="3" />
<FIELDS CUST_ID="5" NAME="Customer1" #SHAPE#="[Geometry]" #ID#="3" />
<FIELDS CUST_ID="6" NAME="Customer2" #SHAPE#="[Geometry]" #ID#="3" />
<FIELDS CUST_ID="7" NAME="Customer3" #SHAPE#="[Geometry]" #ID#="3" />
How do I extract the fields from this XML file ?
How can I represent the data in this in an HTML format ?
and the values one by one inside each colums
How will I do it ?
Ganesh Ram
Ranch Hand

Joined: Jul 20, 2001
Posts: 33
To extract values out of this XML doc, you would have to use a XML DOM Parser. There are many parsers available like xml4j from IBM. These parsers would read the inputstream and give you a Document object back.
From this Document object you can extract the Elements, attributes etc .. using the API.
From representing this XML doc as a HTML doc, you will have to create a XSL.
Microsoft may have tutorials on how to write XSL's.
If the XML doc refers to a XSL and if you use IE to read the XML, it would automatically display the intended HTML.
With Netscape, you would have to the transformation server side.
Shreya Menon
Ranch Hand

Joined: Jul 31, 2001
Posts: 285
Thanks for the response.
My boss wants me to do this thing in Javascript.
Do you know how to use Javascript to extract the values ?
Any suggestion is welcome
L Goundalkar
Ranch Hand

Joined: Jul 05, 2001
Posts: 395
I think you can use DOM Parsing. Since you wanted to do it using Javascript, I think you can use client side Paring. I.E use Microsoft's XMLDOM parser for XSLT on Client Side.
I will try to give you an example after working on it.
you can refer .

L Goundalkar
Sun Certified Programmer for Java 2 Platform

Shreya Menon
Ranch Hand

Joined: Jul 31, 2001
Posts: 285
Hi Goundalkar,
Thanks for offering the help.
Can you Please send the code to ?
Also, if I use the MSXML DOM parser, then how will I make it working in Netscape ?
Sham Jowsaki
Ranch Hand

Joined: May 22, 2001
Posts: 146
Find below the sample coding of client side XML transformation
Transforming it on the Client (Using Javascript)
Here is the simple source code needed to transform the XML file to HTML on the client (try it yourself):
<script language="javascript">
// Load XML
var xml = new ActiveXObject("Microsoft.XMLDOM")
xml.async = false
// Load the XSL
var xsl = new ActiveXObject("Microsoft.XMLDOM")
xsl.async = false
// Transform

I agree. Here's the link:
subject: Representing an xml
It's not a secret anymore!