473,471 Members | 1,995 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Getting HTML back out of XML

I'm having a hell of a time figuring this out. ;o)

OK, thanks to Oleg, I finally figured out how to get XHTML in my XML by
using writeRaw to get it to not encode the XHTML going in.

However, I can't get it back out. I'm transforming my XML using XSLT:

Dim trasformedXML As New System.IO.StringWriter
xslt.Transform(doc, Nothing, trasformedXML, Nothing)
lbl_rulesText.Text = trasformedXML.ToString

The element that also has XHTML in it is transformed SANS the HTML tags.

<xsl:value-of select="text" />

That's returning the text of the node, but none of the HTML elements.

At first, I thought that, well, since it's XHTML, I have more nodes
underneath the TEXT node. But that doesn't explain why it returns all of the
text even the text nested in P tags/nodes.

So, am I just crazy for trying to store unencoded xhtml in an xml file?
Should I encode the html and then pull the XML in as a dataset so I can
select that specific 'field' and unencoded then? Another/better option?

-Darrel

--
================================================== ===============
Win prizes searching google:
http://www.blingo.com/friends?ref=hM...nTqhv-2GE1FNtA
Nov 16 '06 #1
4 1805
darrel wrote:
The element that also has XHTML in it is transformed SANS the HTML tags.

<xsl:value-of select="text" />

That's returning the text of the node, but none of the HTML elements.
xsl:value-of always gives a text node with the string value and not any
elements. If you want to copy the element use e.g.
<xsl:copy-of select="text"/>
if you want to copy the children use e.g.
<xsl:copy-of select="text/*"/>

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 16 '06 #2
>The element that also has XHTML in it is transformed SANS the HTML tags.
>>
<xsl:value-of select="text" />

That's returning the text of the node, but none of the HTML elements.

xsl:value-of always gives a text node with the string value and not any
elements. If you want to copy the element use e.g.
<xsl:copy-of select="text"/>
if you want to copy the children use e.g.
<xsl:copy-of select="text/*"/>
Yep. That makes sense.

So, obviously, I do NOT want to store unencoded xhtml in my xml.

Sounds like the most practical method is to not use XSLT and instead load
the data in a dataset, which would allow me to grab the encoded XHTML as a
field and unencode at that point. Any opinions on that?

Is there a common way to store HTML in XML and get it back out just via
XSLT?

-Darrel
Nov 16 '06 #3
darrel wrote:
So, obviously, I do NOT want to store unencoded xhtml in my xml.

Sounds like the most practical method is to not use XSLT and instead load
the data in a dataset, which would allow me to grab the encoded XHTML as a
field and unencode at that point. Any opinions on that?

Is there a common way to store HTML in XML and get it back out just via
XSLT?
If you really have well-formed XHTML then it is no problem to put that
into an XML document without any escaping as XHTML is XML. And XSLT can
nicely process those elements as well. I am not sure why my suggestion
to use xsl:copy-of lets you conclude that your approach does not work,
it does not work to use xsl:value-of to output elements as xsl:value-of
outputs only the string value in terms of XPath. But xsl:copy-of gives
you a copy of the node so that way you can output the XML or XHTML elements.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 16 '06 #4
If you really have well-formed XHTML then it is no problem to put that
into an XML document without any escaping as XHTML is XML.
I got that far, but...
And XSLT can nicely process those elements as well.
*If* I use copy-of. D'oh! Sorry...I completely missed that in your previous
post (I scanned it as being 'value of')

Copy-of works! Thanks, Martin!

-Darrel
Nov 16 '06 #5

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

Similar topics

4
by: PHPkemon | last post by:
Hi there, A few weeks ago I made a post and got an answer which seemed very logical. Here's part of the post: PHPkemon wrote: > I think I've figured out how to do the main things like...
3
by: dan glenn | last post by:
hi. I want to code a 'preview' function into a guestbook entry page. I can do it with a button that posts, bringing up a whole new page showing a preview of what has been entered, and then the user...
0
by: Jim | last post by:
I need some help getting started with a .NET web project for a commercial site. I am new to .NET and my understanding of some (but not all) of its concepts is a little sparse. I apologize for the...
0
by: Jim | last post by:
This si a repost, I apologize but perhaps my original inquiry got buried under all the usenet spam... I need some help getting started with a .NET web project for a commercial site. I am new to...
11
by: Brett | last post by:
In Yahoo mail, I click the Inbox link and see my messages. If I view source, I don't have HTML which contains the URL of each message. The source HTML contains javascripting and framesets. This...
5
by: Brian Henry | last post by:
I have a page which reads an article from the database it has 1 text box, 2 dropdown lists, and a longreat HTML text box. I load the information from the database when the page is set to edit mode...
2
by: Hitesh | last post by:
Hi, I am getting the response from another Website by using the HttpHandler in my current site. I am getting the page but all the images on that page are not appearing only placeholder are...
6
by: hemant.singh | last post by:
Hi all, I am trying to get a way by which I'll know exactly when user goes out of my site by clicking on close button in browser, So that w/e user click close button in browser, I can send a...
2
by: rustyc | last post by:
Well, here's my first post in this forum (other than saying 'HI' over in the hi forum ;-) As I said over there: ... for a little side project at home, I'm writing a ham radio web site in...
7
vikas251074
by: vikas251074 | last post by:
I am getting error above in following code since few days giving tension day and night. How can I solve this? I am facing since Oct.25. in line no. 362 After doing a lot of homework, I am...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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
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
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
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
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 ...

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.