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
Solved

Modify and re parse bad XML data?

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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

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…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

860 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