Extract text from XML file (multiple lines) VOL2

erikgrave1

New Member
Joined
Jul 22, 2015
Messages
9
Hi all,
in this thread we solved, how to read data from an XML file with VBA. Everything was working perfect, until the developer installed a patch for encoding :eeek:

This is part of working version before the patch, it throws a strange error in .responseText

Code:
Set XMLdoc = CreateObject("Microsoft.XMLDOM")
XMLdoc.SetProperty "SelectionLanguage", "XPath"
XMLdoc.async = False

With CreateObject("MSXML2.XMLHTTP")
    .Open "GET", myURL, False
    .Send
    [COLOR=#ff0000]XMLdoc.LoadXML .responseText[/COLOR]
End With

    Set recordNodes = XMLdoc.SelectNodes("root/record")
    For Each recordNode In recordNodes
        Cells(row, 2) = recordNode.ChildNodes(1).nodeTypedValue
        Cells(row, 3) = recordNode.ChildNodes(0).nodeTypedValue
        row = row + 1
    Next
    x = ""
    If row = rowse Then Exit Sub
    Next i

and this is previous version of XML UTF-8 and working :
<root>
<record type="tsacinv/system">< root>
< record type="tsacinv/system">
< status>in operation
< systemid>S21157648
< /record>
< /root></record>
</root>
And this is the new - not working XML :
< ?xml version="1.0" encoding="iso-8859-1" ?>
< root>
< record type="tsacinv/system">
< status>in operation
< systemid>S21157648
< /record>
< /root>

And the Error in VBA is : run-time error '-107896658 (c00ce56e)'

Do you have any idea how to "format" or "read" and handle the XML as before ?
Thank you all !
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top