Link to home
Start Free TrialLog in
Avatar of MikeCombe
MikeCombeFlag for United States of America

asked on

XML parse does not preserve html characters

I read an xml file and parse the "Description" node, then save it into a database.

Using the code below, I would expect that the content of the "Description" would be:
<p>see spot run</p><p>see spot sit</p>

However, the data actually saved in the database is"
see spot run see spot sit

It is missing the html tags of <p></p>

Is this due to the method of reading the xml node?
Description = _Description (0).InnerText

For testing purposes, I email myself the value of "Description" before the database insert.
So the database insert is not my problem.

* * * How do I preserve the html characters in the xml so they get saved in the database along with the xml content ?


Here's my xml
<body.content>
<p>see spot run</p><p>see spot sit</p>
<\body.content>


Reading my xml
Dim _Description As XmlNodeList = Nothing
Dim _doc As New XmlDocument()
Dim Description As String = ""

_doc.Load(fileName)
If _doc.SelectSingleNode("//body.content") IsNot Nothing Then
     _Description = _doc.GetElementsByTagName("body.content")
End If
If _Description IsNot Nothing Then
    Description = _Description (0).InnerText
End If
Avatar of zc2
zc2
Flag of United States of America image

please try:

Description = _Description (0).xml
Avatar of MikeCombe

ASKER

no....I get the error....

'xml' is not a member of 'System.Xml.XmlNode'
ASKER CERTIFIED SOLUTION
Avatar of zc2
zc2
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Perfect !!!

Thanks.
Welcome.