Solved

Modify and re parse bad XML data?

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
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…

730 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