• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Representing an xml

 
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have an XML file that looks like this
<?xml version="1.0"?>
<RESPONSE>
<FEATURES>
<FEATURE>
<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" />
</FEATURE>
</RESPONSE>
How do I extract the fields from this XML file ?
How can I represent the data in this in an HTML format ?
ie,
CUST_ID Name SHAPE ID
and the values one by one inside each colums
How will I do it ?
Thanks,
Maya
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 285
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ganesh,
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
Maya
 
Ranch Hand
Posts: 395
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
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 www.w3schools.com/xsl .
Thanks.

------------------
L Goundalkar
lggoundalkar@hotmail.com
Sun Certified Programmer for Java 2 Platform
 
Shreya Menon
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Goundalkar,
Thanks for offering the help.
Can you Please send the code to google_n@hotmail.com ?
Also, if I use the MSXML DOM parser, then how will I make it working in Netscape ?
Thanks,
Maya
 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
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):
<html>
<body>
<script language="javascript">
// Load XML
var xml = new ActiveXObject("Microsoft.XMLDOM")
xml.async = false
xml.load("cd_catalog.xml")
// Load the XSL
var xsl = new ActiveXObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load("cd_catalog_sort.xsl")
// Transform
document.write(xml.transformNode(xsl))
</script>
</body>
</html>

Cheers
Jowsaki
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic