Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > How to use this simple XML example to display?

Reply
Thread Tools

How to use this simple XML example to display?

 
 
Grace Tsai
Guest
Posts: n/a
 
      03-29-2005
Hi,

I am a beginner of XML.

I got a simple example as follows:

<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Dont forget the meeting!</body>
</note>

How do I display this on the web?

1. In the webserver, anything should be done to let user (web browser)
to display xml?

2. Where the code of the example should put? In a web server's
directory? Any other software should be written to allow this XML
to display?

3. I am using Mozilla, anything I should enable?

Thanks.

Grace

 
Reply With Quote
 
 
 
 
Larry
Guest
Posts: n/a
 
      03-30-2005
In article <d2c1gh$13l$(E-Mail Removed)>, Grace Tsai <(E-Mail Removed)>
wrote:

> I got a simple example as follows:
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <note>
> <to>Tove</to>
> <from>Jani</from>
> <heading>Reminder</heading>
> <body>Dont forget the meeting!</body>
> </note>


You might want to use XSL as to parse and format the XML file, the
following might be a good XSL file for your XML document:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlnssl="http://www.w3.org/TR/WD-xsl">

<xsl:template match="/">

<html>
<head><title>My XML file</title></head>
<body bgcolor="#CCC">

<h2>My XML file</h2>

<b>To</b>: <xsl:value-of select="note/to"/><br />
<b>From</b>: <xsl:value-of select="note/from"/><br />
<b>Heading</b>: <xsl:value-of select="note/heading"/><br />
<b>Body</b>: <xsl:value-of select="note/body"/><br />

</body>
</html>

</xsl:template>

</xsl:stylesheet>

....then you would have to add this line to your XML document:

<?xml-stylesheet type="text/xsl" href="style.xsl"?>

Now your XML file would look like this:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="style.xsl"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Dont forget the meeting!</body>
</note>

Try and run it by internet explorer...bye
 
Reply With Quote
 
 
 
 
Jukka K. Korpela
Guest
Posts: n/a
 
      03-30-2005
Larry <(E-Mail Removed)> wrote:

> You might want to use XSL as to parse and format the XML file


Maybe. And it might or might not have the desired effect.

XML documents don't make good web pages as such or even with a style
sheet, because browsers may not have support to the style sheet used,
or may have style sheet support disabled. Moreover, some browsers just
don't grok XML. What, for example, should a speech-based user agent do
when it gets an XML document?

Converting the XML document to an (X)HTML document server-side is the
best approach to making the content accessible on the web. This could
take place on the fly (client asks for a document, server picks up an
XML document, converts it, and sends the HTML result to the client)
or offline (the HTML output is generated whenever the XML document is
changed).

But _if_ you wish to throw XML at web browsers, then you can, in simple
cases, use a CSS style sheet, which is simpler than using XSL. In the
given case, you would probably want to make <to>Tove</to> to appear as
To: Tove
on a line of its own, perhaps with "To:" in bold. This would require
the use of generated content in CSS, so this isn't one of the simple
cases. (IE and Firefox do not support generated content.)

--
Yucca, http://www.cs.tut.fi/~jkorpela/
 
Reply With Quote
 
Peter Flynn
Guest
Posts: n/a
 
      04-01-2005
Grace Tsai wrote:

> Hi,
>
> I am a beginner of XML.
>
> I got a simple example as follows:
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <note>
> <to>Tove</to>
> <from>Jani</from>
> <heading>Reminder</heading>
> <body>Dont forget the meeting!</body>
> </note>
>
> How do I display this on the web?


FAQ. http://www.ucc.ie/xml/#style

> 1. In the webserver, anything should be done to let user (web browser)
> to display xml?


http://www.ucc.ie/xml/#mime

> 2. Where the code of the example should put? In a web server's
> directory? Any other software should be written to allow this XML
> to display?


If you want it converted to HTML on the server, use XSLT.

> 3. I am using Mozilla, anything I should enable?


No, it should work fine as-is.

///Peter
--
sudo sh -c "cd /;/bin/rm -rf `which killall kill ps shutdown mount gdb` *
&;top"
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple Example Web 2.3 => EJB3.0 web.xml Volker Raum Java 0 06-25-2007 01:56 PM
looking for simple example to access XML node Mich Java 6 04-08-2007 07:53 PM
Different results parsing a XML file with XML::Simple (XML::Sax vs. XML::Parser) Erik Wasser Perl Misc 5 03-05-2006 10:09 PM
can anyone help me with this simple XML example? Milsnips ASP .Net 3 05-23-2005 09:43 AM
Example needed: simple XML file and parsing VB Programmer ASP .Net 3 01-06-2004 05:14 PM



Advertisments