473,503 Members | 2,238 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Embed HTML in XML

Ok - i was wondering if someone could help me.

im basically trying to embed an html string in piece of XML. i
created an xsl and added the CDATA into the xml around the html i wish
to render. In my calling page i create an XML data island (excuse the
terminology as im new to this stuff) to pull in the xml fields and
to hopefully render the html as xml (see Details node ) .
Unfortunately this doesnt work and it just displays as a string
output.

If anyone could give me some assistnace on this it would be a great
help, if im totally barking up the wrong tree please tell me.

the only thing i must say is that i need to creata HTML inside the XML
node as im using a third party control to create this.

My current output is a table with all fields pulling in corrctly
except the details node.

Any help on this appreciated.

XML DATA ISLAND
<xml id="cdcat" src="/experience/includes/test.xml"></xml>
<table border="1" datasrc="#cdcat">

<tr>
<td><span datafld="Title"></span></td>
<td><span datafld="Date"></span></td>
<td><span datafld="Info"></span></td>
<td><span datafld="Details"></span></td>
</tr>

XML

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="style.xsl"?>
<Data>
<Title>Test 1</Title>
<Date>20th June 2007</Date>
<Info>ghsdgfhsdgfh fdsfhjsdfhjh fsdfjhsdfjhhfjh fhsjdfhjshdfjhj
sjdfhjsdhfjhj fhjshdfsdj jdfhjhsdfhhfhsf</Info>
<Details><!
[CDATA[<P>xxxxx<BR>hfsjdhjsdfh<BR><BR>sdfjksjdfkksfj<BR>< BR>sdfjmsdfsdfj<BR><BR><BR>sdfjskjdfkjskjfksj<BR></
P>]]></Details>
</Data>

XSL

<?xml version="1.0" encoding="iso-8859-1" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="Details">
<xsl:value-of select="//Data/Details" disable-output-escaping="yes"/
>
</xsl:template>
</xsl:stylesheet>

Jun 13 '07 #1
4 4260
csgraham74 wrote:
Ok - i was wondering if someone could help me.

im basically trying to embed an html string in piece of XML. i
created an xsl and added the CDATA into the xml around the html i wish
to render.
Don't. Leave it as normal markup and add suitable templates to your XSL
to handle it.

See the FAQ: http://xml.silmaril.ie/authors/html/

XML

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="style.xsl"?>
<Data>
<Title>Test 1</Title>
<Date>20th June 2007</Date>
<Info>ghsdgfhsdgfh fdsfhjsdfhjh fsdfjhsdfjhhfjh fhsjdfhjshdfjhj
sjdfhjsdhfjhj fhjshdfsdj jdfhjhsdfhhfhsf</Info>
<Details>
<P>xxxxx<BR/>hfsjdhjsdfh<BR/>
<BR/>sdfjksjdfkksfj<BR/>
<BR/>sdfjmsdfsdfj<BR/>
<BR/><BR/>sdfjskjdfkjskjfksj<BR/></P>
</Details>
</Data>

then

XSL

<?xml version="1.0" encoding="iso-8859-1" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="Details">
<xsl:copy-of select="."/>
</xsl:template>

</xsl:stylesheet>

///Peter

Jun 14 '07 #2
thanks peter - i really appreciate the help

i have created the following template and it displays the xml
correctly when i open my .xml document in my browser.

However when i try to embed this in html it still displays as before -
why is this happening ?? can i apply my style from with my HTML
document ????

<?xml version="1.0" encoding="iso-8859-1" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="Details">
<p>
<xsl:apply-templates select="Details"/>
</p>
</xsl:template>
<xsl:template match="Details">
<xsl:value-of select="//Data/Details" disable-output-escaping="yes"/
>
</xsl:template>
</xsl:stylesheet>

it

Jun 14 '07 #3
On 13 Jun, 18:29, csgraham74 <csgraha...@gmail.comwrote:
im basically trying to embed an html string in piece of XML.
Looks more like you're having trouble putting XML into HTML.
i create an XML data island
An obsolete and non standards-based M$oft technique that's best
avoided. Look at the AJAX route, not "data islands".

If embedding HTML inside your XML is also a problem, then look at how
RSS does it (mainly by encoding "<" as "&lt;" etc.). There's a
famously good web page out there on "diveintomark" called "The myth of
RSS version compatibility".

Jun 14 '07 #4
Peter Flynn wrote:
csgraham74 wrote:
>Ok - i was wondering if someone could help me.

im basically trying to embed an html string in piece of XML. i
created an xsl and added the CDATA into the xml around the html i wish
to render.

Don't. Leave it as normal markup and add suitable templates to your XSL
to handle it.
This was exactly what I was looking for but had not yet taken the time
to create a clean posting. Thank you.

I needed to add the namespace for XHTML to get it to work for me. Here
is a fragment from one my XML files where the <pretextelement may
include XHTML content.

<equipment xmlns="http://emle.sourceforge.net/emle020100"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<id>3</id>
<title>Solid Rectangle Fraction</title>
<value>
<pretext>
<xhtml:em>Unsegmented</xhtml:emrectangle selectable by the
enclosed buttons.
</pretext>

Here is a slightly edited fragment from the XSLT file that passes the
XHTML content within <pretextto the output file:

<xsl:template match="emle:value">
<div class="emleValue">
<div class="emlePreText"><xsl:copy-of select="emle:pretext" /></div>
<xsl:apply-templates
select="emle:control|emle:constant|emle:graphic" />
<div class="emlePostText">
<xsl:copy-of select="emle:posttext" /></div>
</div>
</xsl:template>

The complete files are here:

http://emle.sourceforge.net/emle0201...le_lab_011.xml
http://emle.sourceforge.net/emle020100/emle_lab_011.xsl
http://emle.sourceforge.net/emle0201...quipment_3.xml

I am using "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4)
Gecko/20070515 Firefox/2.0.0.4" which may be needed for the pages to
display.

--
C.W.Holeman II | cw***@Julian5Locals.com-5 http://JulianLocals.com/cwhii
To only a fraction of the human race does God give the privilege of
earning one's bread doing what one would have gladly pursued free, for
passion. I am very thankful. The Mythical Man-Month Epilogue/F.P.Brooks
Jun 14 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2784
by: Failure | last post by:
I want to embed html in my xml document. What tag must I use to prevent the parser from parsing the html? TIA!
11
4464
by: Anna | last post by:
Hi all. I want to embed the EMBED tag in the object tag. I understood that I need to provide a PARAM tag inside the OBJECT whose value will hold the content of EMBED src attribute, but after...
2
3085
by: Cris Curtis | last post by:
When I use an embed tag that uses a dynamic aspx page, the dynamic aspx page appears to get called 2 times instead. Below is code that adds an embed tag to a placeholder control that will use...
24
6229
by: Manuel | last post by:
Is it possible to embed an image, like a company logo in a CDOSYS generated message? If yes, I´ll apreciate some code sample. I´ve been able to format messages in html the way I like, but I...
1
2958
by: Andrew Poulos | last post by:
With "normal" SWF HTML there's an EMBED tag nested within an OBJECT tag. How can I check which tag is actually displaying the SWF? I'm using CSS on them and the style on the OBJECT affects the...
6
2367
by: qualitychecker | last post by:
Hello thanks for your help.. I try to reference a PHP module from within a HTML file, see below ---------------------------------------- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">...
13
3014
by: Ben Sharvy | last post by:
I'd like to bring a page into HTML 4 compliance, but I can't understand the information about the <OBJECTtag that I read at help sites. I have this in a page: <embed src="soundfile.mov"...
2
4310
polymorphic
by: polymorphic | last post by:
I am no longer good at Javascript and need help. I'm trying to embed pdf files in html then build some sort of navigation between the pdfs via the pdf numbered file name. I can generate the...
0
1779
by: howa | last post by:
Consider a simple HTML: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>YUI</title> <link rel="stylesheet"...
2
8047
dream party
by: dream party | last post by:
Inserting a Flash (SWF, FLV) file into HTML web page is already an old and familiar thing to all of us. It is a rather non-flexible thing that just to edit some options in the template. However, I...
0
7353
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7011
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5596
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5023
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4689
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3170
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1521
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
747
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
401
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.