• 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

Sample XML programs

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i want to learn XML.so kindly help me to know about how to compile and run XML programs. and i want some simple XML examples
 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi megala,
Try this example
/*** samp2.xml **/
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="samp2.xsl"?>
<CATALOG>
<CD>
<TITLE>Empire Burlesque</TITLE>
<ARTIST>Bob Dylan</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>10.90</PRICE>
<YEAR>1985</YEAR>
</CD>
<CD>
<TITLE>Return of the Judai</TITLE>
<ARTIST>Judas Priest</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>20.90</PRICE>
<YEAR>1995</YEAR>
</CD>
<CD>
<TITLE>Dangerous</TITLE>
<ARTIST>Michael Jackson</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Sony</COMPANY>
<PRICE>30.00</PRICE>
<YEAR>1992</YEAR>
</CD>
</CATALOG>
/****samp2.xsl ****/
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<body>
<table border="2" bgcolor="cyan">
<tr>
<th>Title</th>
<th>Artist</th>
<th>Price</th>
<th>Company</th>
</tr>
<xsl:for-each select="CATALOG/CD">
<tr>
<td><xsl:value-of select="TITLE"/></td>
<td><xsl:value-of select="ARTIST"/></td>
<td><xsl:value-of select="PRICE"/></td>
<td><xsl:value-of select="COMPANY"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet><?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<body>
<table border="2" bgcolor="cyan">
<tr>
<th>Title</th>
<th>Artist</th>
<th>Price</th>
<th>Company</th>
</tr>
<xsl:for-each select="CATALOG/CD">
<tr>
<td><xsl:value-of select="TITLE"/></td>
<td><xsl:value-of select="ARTIST"/></td>
<td><xsl:value-of select="PRICE"/></td>
<td><xsl:value-of select="COMPANY"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
copy these 2 files in a directory..And call samp2.xml file in a browser..u will get the following in a table format..
Title Artist Price Company
Empire Burlesque Bob Dylan 10.90 Columbia
Return of the Judai Judas Priest 20.90 Columbia
Dangerous Michael Jackson 30.00 Sony
welcome to xml and All the best in learning...
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

XML is a technology to specify and render data. Its NOT
a traditional computer language like C/C++/Java/...
that you write programs and compile to see results
(atleast not in that sense).
Its more of a "how to represent this data?" and a lot more...
regds.
- satya
 
Sunglasses. AKA Coolness prosthetic. This tiny ad doesn't need shades:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic