By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,222 Members | 1,436 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,222 IT Pros & Developers. It's quick & easy.

Reading XML with HTML tags

P: n/a
Hi all

I have a XML file with the following:

<Step step="1">
<Text><b>Chapter 1</b>
This is a test. Click <b><i>Load</i></b>
</Text>
</Step>

I'd like to read this node and bring the HTML tags as well. I'm reading
using node["Text"].InnerText but looks like the InnerText remove the
HTML tags from it. Does someone knows how I can read the node with the
HTML tags on it?

Thanks!

Jun 15 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a


em*******@gmail.com wrote:

I'd like to read this node and bring the HTML tags as well. I'm reading
using node["Text"].InnerText but looks like the InnerText remove the
HTML tags from it. Does someone knows how I can read the node with the
HTML tags on it?


You could use InnerXml instead of InnerText.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jun 15 '06 #2

P: n/a
Thanks! It worked!

Martin Honnen wrote:
em*******@gmail.com wrote:

I'd like to read this node and bring the HTML tags as well. I'm reading
using node["Text"].InnerText but looks like the InnerText remove the
HTML tags from it. Does someone knows how I can read the node with the
HTML tags on it?


You could use InnerXml instead of InnerText.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


Jun 15 '06 #3

P: n/a
How about to save with the tags?

I tried InnerXml as well and it blows up. With InnerText stays really
messed up.

em*******@gmail.com wrote:
Thanks! It worked!

Martin Honnen wrote:
em*******@gmail.com wrote:

I'd like to read this node and bring the HTML tags as well. I'm reading
using node["Text"].InnerText but looks like the InnerText remove the
HTML tags from it. Does someone knows how I can read the node with the
HTML tags on it?


You could use InnerXml instead of InnerText.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


Jun 15 '06 #4

P: n/a
emferrari,
The important point here is to be able to understand what "well - formed"
means.
You don't say where you got this "XML". but I suspect it was simply
"concocted".

if you want to store markup you need to enclose it in CDATA sections.

If you want to parse HTML AS IF it were legal XML, take a look at Simon
Mourier's HtmlAgilityPack.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"em*******@gmail.com" wrote:
Hi all

I have a XML file with the following:

<Step step="1">
<Text><b>Chapter 1</b>
This is a test. Click <b><i>Load</i></b>
</Text>
</Step>

I'd like to read this node and bring the HTML tags as well. I'm reading
using node["Text"].InnerText but looks like the InnerText remove the
HTML tags from it. Does someone knows how I can read the node with the
HTML tags on it?

Thanks!

Jun 15 '06 #5

P: n/a
Ok, agreed.

I don't want to use third part component. There is another way?

Peter wrote:
emferrari,
The important point here is to be able to understand what "well - formed"
means.
You don't say where you got this "XML". but I suspect it was simply
"concocted".

if you want to store markup you need to enclose it in CDATA sections.

If you want to parse HTML AS IF it were legal XML, take a look at Simon
Mourier's HtmlAgilityPack.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"em*******@gmail.com" wrote:
Hi all

I have a XML file with the following:

<Step step="1">
<Text><b>Chapter 1</b>
This is a test. Click <b><i>Load</i></b>
</Text>
</Step>

I'd like to read this node and bring the HTML tags as well. I'm reading
using node["Text"].InnerText but looks like the InnerText remove the
HTML tags from it. Does someone knows how I can read the node with the
HTML tags on it?

Thanks!


Jun 15 '06 #6

P: n/a
Simon's "component" is free and open-source, written in C#, is very
sophisticated, and no, there aren't really any "other ways" unless you want
to use similar code to his.

Essentially, you are creating an HtmlDocument object that behaves like a
well-formed XmlDocument and permits accurate xpath operations.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"em*******@gmail.com" wrote:
Ok, agreed.

I don't want to use third part component. There is another way?

Peter wrote:
emferrari,
The important point here is to be able to understand what "well - formed"
means.
You don't say where you got this "XML". but I suspect it was simply
"concocted".

if you want to store markup you need to enclose it in CDATA sections.

If you want to parse HTML AS IF it were legal XML, take a look at Simon
Mourier's HtmlAgilityPack.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"em*******@gmail.com" wrote:
Hi all

I have a XML file with the following:

<Step step="1">
<Text><b>Chapter 1</b>
This is a test. Click <b><i>Load</i></b>
</Text>
</Step>

I'd like to read this node and bring the HTML tags as well. I'm reading
using node["Text"].InnerText but looks like the InnerText remove the
HTML tags from it. Does someone knows how I can read the node with the
HTML tags on it?

Thanks!


Jun 15 '06 #7

P: n/a


em*******@gmail.com wrote:
How about to save with the tags?

I tried InnerXml as well and it blows up.


What exactly are you trying to save in which way? Provide some code
snippets you are using and give precise error messages you get, then we
can hopefully solve things. But with a description like "it blows up" it
is not possible to tell what you tried and in which way it failed.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jun 16 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.