XML special characters inside attribute value causes error

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<span style="color:#222222; font-family:Droid Serif,Georgia,Times New Roman,serif; font-size:14px; line-height:23px; text-align:left I am currently importing large number of XML files which were generated by VB6 application using MSXML. I read these
files into stream for processing.<br style="font-size:14px; font-family:Droid Serif,Georgia,Times New Roman,serif; color:#222222; line-height:23px; text-align:left
<span style="color:#222222; font-family:Droid Serif,Georgia,Times New Roman,serif; font-size:14px; line-height:23px; text-align:left In some XMLs the Attributes value contains XML predefines special characters such as:<br style="font-size:14px; font-family:Droid Serif,Georgia,Times New Roman,serif; color:#222222; line-height:23px; text-align:left
<span style="color:#222222; font-family:Droid Serif,Georgia,Times New Roman,serif; font-size:14px; line-height:23px; text-align:left & < > " <br style="font-size:14px; font-family:Droid Serif,Georgia,Times New Roman,serif; color:#222222; line-height:23px; text-align:left
<span style="color:#222222; font-family:Droid Serif,Georgia,Times New Roman,serif; font-size:14px; line-height:23px; text-align:left This causes the application to throw error for example such attribute produces error:<br style="font-size:14px; font-family:Droid Serif,Georgia,Times New Roman,serif; color:#222222; line-height:23px; text-align:left
<span style="color:#222222; font-family:Droid Serif,Georgia,Times New Roman,serif; font-size:14px; line-height:23px; text-align:left lastname = " Jon "Jarvis"
<span style="color:#222222; font-family:Droid Serif,Georgia,Times New Roman,serif; font-size:14px; line-height:23px; text-align:left using (XmlReader reader = XmlReader.Create(new StreamReader(ms, Encoding.GetEncoding("wind<wbr style="font-size:14px; font-family:Droid Serif,Georgia,Times New Roman,serif; color:#222222; line-height:23px; text-align:left <span style="color:#222222; font-family:Droid Serif,Georgia,Times New Roman,serif; font-size:14px; line-height:23px; text-align:left ows-1252")<wbr style="font-size:14px; font-family:Droid Serif,Georgia,Times New Roman,serif; color:#222222; line-height:23px; text-align:left <span style="color:#222222; font-family:Droid Serif,Georgia,Times New Roman,serif; font-size:14px; line-height:23px; text-align:left )))<br style="font-size:14px; font-family:Droid Serif,Georgia,Times New Roman,serif; color:#222222; line-height:23px; text-align:left
<span style="color:#222222; font-family:Droid Serif,Georgia,Times New Roman,serif; font-size:14px; line-height:23px; text-align:left {<br style="font-size:14px; font-family:Droid Serif,Georgia,Times New Roman,serif; color:#222222; line-height:23px; text-align:left
<span style="color:#222222; font-family:Droid Serif,Georgia,Times New Roman,serif; font-size:14px; line-height:23px; text-align:left XmlDoc.Load(reader); <-- error is thrown<br style="font-size:14px; font-family:Droid Serif,Georgia,Times New Roman,serif; color:#222222; line-height:23px; text-align:left
<span style="color:#222222; font-family:Droid Serif,Georgia,Times New Roman,serif; font-size:14px; line-height:23px; text-align:left }
<p style="text-align:left <span style="color:#222222 <span style="font-size:14px; line-height:23px Any direction is appreciated it.

View the full article
 
Back
Top