Solved

XmlDocument Load xml

Posted on 2010-11-11
1
674 Views
Last Modified: 2012-05-10
I have a stringbuilder object that I want to load into an Xmldocument.
I concat the nodes and elements within code. And I amhandling escape characters with CDATA in certain cases.

I need to know how to handle excape characters within a grouping.
I have an element called codes which could have one or more code's which has two attributes code and descriptionn. I need to handle if description has escape characters.

Should the concatanation of stringbuilder look something like this?
<code code="200" description="[CDATA[ORDER 100  & two]]"/>
<record>

<userid datatype='order'>151</webuserid>

<txtlastname datatype='order'><![CDATA[ANNIE]]></txtlastname>

<txtfirstname datatype='order'><![CDATA[SMITH]]></txtfirstname>

<txtaddress datatype='order'><![CDATA[79 TEST DR]]></txtaddress>

<txtcity datatype='order'><![CDATA[SOMEWHERE]]></txtcity>

<txtstate datatype='order'><![CDATA[NJ]]></txtstate>

<txtzip datatype='order'><![CDATA[08083]]></txtzip>

<codes datatype='order'>

<code code="100" description="ORDER 100"/>

<code code="200" description="ORDER 100  & two"/>

</codes>

</record>





Dim sb As New StringBuilder()

Dim XmlDoc As New System.Xml.XmlDocument

''''some logic to append values''''

sb.Append("'><![CDATA[")

   '''''append value''''''      

sb.Append("]]></")

XmlDoc.LoadXml(sb.ToString)

Open in new window

0
Comment
Question by:countrymeister
1 Comment
 
LVL 3

Accepted Solution

by:
xeonol earned 500 total points
Comment Utility
If you want to escape the special characters in xml, a simple way is to replace them with escaped strings:
< -> <
> -> >
" -> &quot;
' -> &apos;
& -> &amp;

You can refer to http://weblogs.sqlteam.com/mladenp/archive/2008/10/21/Different-ways-how-to-escape-an-XML-string-in-C.aspx for some different ways.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now