Reading XML with HTML tags

  • Thread starter Thread starter emferrari
  • Start date Start date
E

emferrari

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!
 
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.
 
Thanks! It worked!

Martin said:
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.
 
How about to save with the tags?

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

Thanks! It worked!

Martin said:
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.
 
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
 
Ok, agreed.

I don't want to use third part component. There is another way?
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




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!
 
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




Ok, agreed.

I don't want to use third part component. There is another way?
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




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!
 
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.
 
Back
Top