Solved

Modify and re parse bad XML data?

Posted on 2006-07-19
2
293 Views
Last Modified: 2010-08-05
Currently I load my XML in VS 2005 like this:
xmlDoc.Load(Url)
The XML returned is occasionally badly formed like below.

<?xml version="1.0" encoding="UTF-8" ?>
<chain ...>
 ... number of chain records ...
<?xml version="1.0" encoding="UTF-8" ?>
<error>
 ... description of what's wrong.
</error>

As you can see it's missing the closing tag </chain>.
Is it possible to modify the read XML data, remove the error part, add the closing chain tag and parse again?


This might be an alternative, so far I didn't try anything with it, still how to change the read data?

      Dim webRequest As System.Net.HttpWebRequest
      Dim webResponse As System.Net.HttpWebResponse
      webRequest = CType(System.Net.WebRequest.Create(Url), System.Net.HttpWebRequest)
      webRequest.AllowAutoRedirect = True
      webRequest.Timeout = DEF_TIMEOUT
      webResponse = CType(webRequest.GetResponse(), System.Net.HttpWebResponse)
      Dim sr As New System.IO.StreamReader(webResponse.GetResponseStream(), System.Text.Encoding.UTF8)
      xmlDoc.Load(sr.ReadToEnd())
      sr.Close()
0
Comment
Question by:NicoLaan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Accepted Solution

by:
Zwabbert earned 250 total points
ID: 17182876
Well, you're almost there.

Dim xml As String
xml = sr.ReadToEnd()
...
Code to change the XML string.
...
xmlDoc.LoadXml(xml)
0
 
LVL 4

Author Comment

by:NicoLaan
ID: 17182887
Yeah, I'd figured that one out as well by now.
Still thanks for the good answer, you deserve the points.
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

724 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