Dim MyRawXML as string
MyRawXML="<?xml version="1.0" encoding="utf-8"?>??<response>???<result>success</result>???<get_users_response>???<users>????<user>bill</user>????<user>sam</user>????<user>fred</user>???</users>???</get_users_response>??</response>"
I have literally cut and pasted this code form the documentation:
[code] Dim xdoc As XmlDocument
Dim node As XMLNode
Dim count As Integer
Dim out As String
// create a new document
xdoc = New XmlDocument
xdoc.PreserveWhitespace = False
// load and parse the xml in the TextArea, parse_InputText
xdoc.LoadXml(MyRawXML) <—Error here![/code]
I’m not sure about “easily” – years ago I had a routine that just went character by character and removed any unusual control-type characters that RS’ XML engine didn’t like. It was the only way I could get it to work because the XML was coming in badly formed and my app would crash before I could even load the XML (I opened it as a string and processed it first, then sent the clean one to loadXML and it worked).
Today I’d probably do that with a regex looking for control characters.
I’ve been called a lot of things over the years and surprisingly this is among the most common
[quote=31052:@Jay Menna]I have pulled out the offending ?and it works fine.
Can anyone think of a way to clean the bad stuff out easily? Regex perhaps?[/quote]
65533 ?
I’d look at the bytes in the debugger - I have some suspicions but better to be sure.
Basically you have a string in some encoding (presuming you DID call define encoding on it) and the character that is there is not one that is in whatever encoding its defined to be
Really seems to right thing is to call define encoding and see what they are