Link to home
Start Free TrialLog in
Avatar of EDDYKT
EDDYKTFlag for Canada

asked on

XML inside XML

I have the following xml (just make it up, the idea is to show xml inside the xml)

<?xml version="1.0" encoding="utf-8"?>
<GetResult>
    <?xml version="1.0" encoding="utf-8"?><GetResultString>1.1</GetResultString>
</GetResult>

I use DOM to load the above string and get an error
dim s as string
Dim doc As New MSXML2.DOMDocument

s = "<?xml version=""1.0"" encoding=""utf-8""?>"
s = s & "<GetResult>"
s = s & "<?xml version=""1.0"" encoding=""utf-8""?>"
s = s & "<GetResultString>"
s = s & "1.1"
s = s & "</GetResultString>"
s = s & "</GetResult>"
doc.async = False
doc.validateOnParse = False
doc.loadXML s            ' where s is the above string

The error is

?doc.parseError.errorCode
-1072896681
?doc.parseError.reason
Invalid xml declaration.

I would like to use DOM to get the string of the inner xml and set it in another DOM to parse data
What can i make it work?

Don't tell me to use instr to parse data, the about is just an example. The actual xml is different.

VB6 and sp6
ASKER CERTIFIED SOLUTION
Avatar of DiscoNova
DiscoNova
Flag of Finland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of EDDYKT

ASKER

The xml string comes back from web server and i cannot do anything on it.

That's the problem, It's like a chicken and egg problem

I need to parse it with dom to get the xml string. not encode it before to pass it to dom

8->
Hmm... ok, that comlicates things somewhat :)

Can you be certain that the response is always like

<?xml version="1.0" encoding="utf-8"?>
<GetResult>
[THE PART YOU ARE REALLY INTERESTED IN]
</GetResult>

...or is there a possibility that it will contain something totally different?

If it is, you could just take the first, second and last line away (in any way you see fit) and handle what is left as the actual result. I'm not entirely certain if this falls under "use instr to parse data", but I decided to give it a go nonetheless ;)
Avatar of EDDYKT

ASKER

Again that is example of the test xml
Avatar of EDDYKT

ASKER

the actual part may include SOAP envlope that you may not want to know