Solved

Modify and re parse bad XML data?

Posted on 2006-07-19
2
290 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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
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 …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

815 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

11 Experts available now in Live!

Get 1:1 Help Now