Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

importing simple xml strings into html

8:22 am on Mar 31, 2011 (gmt 0)

New User

5+ Year Member

joined:Mar 31, 2011
posts: 1
votes: 0

Hi, I have a very simple xml file like this:

<Text1>first text going to website
<Text2>second text going to website

I need my html(index) file to pick up the text from the xml file. What is the simplest solution how to do this? Could anyone please give me help in how to code this?

The nearest I am a solution, is doing as follows - making a xsl file looking something like this:

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
<xsl:template match="/">
<xsl:value-of select="MyText/Text1" /><br/>

and linking to it in the xml file via this line

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

But I don't know how to put this in the right place of my html file.

Or are there other ways to do this?
I appreciate all the help I can get!
5:56 pm on May 11, 2011 (gmt 0)

Senior Member from CA 

WebmasterWorld Senior Member httpwebwitch is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Aug 29, 2003
votes: 0

your best bet is to use a server-side programming language like PHP, C#, Java, Perl, Ruby, or whatever you're comfortable with... use it to grab the XML file, parse it to get the text, and output that into your HTML layout.

XSL transformation is typically performed on an entire document; it's not possible (AFAIK) to drop a little piece of it into HTML.

It's possible to do it with JavaScript, but I don't recommend it.