+ Reply to Thread
Results 1 to 3 of 3

LoadXML Fails

  1. #1
    Registered User
    Join Date
    10-03-2012
    Location
    Colorado
    MS-Off Ver
    Excel 2010
    Posts
    2

    LoadXML Fails

    Hello - I am trying to load an XML file into a DOMDocument and no matter what I do, the LoadXML method fails (ie returns FALSE). (I'm new, so I don't know if there's a special format for code snippets.) The code looks like this
    Sub Test()

    Dim objXMLDoc As MSXML2.DOMDocument
    Dim loaded As Boolean

    Set objXMLDoc = New MSXML2.DOMDocument
    objXMLDoc.async = False
    loaded = objXMLDoc.LoadXML("<chapter><title>Data Model</title><section><title>Syntax For Data Model</title></section></chapter>)")
    I first tried loading from a file, then opened the file and manually built a strXML from the file, and then typed the XML code in explicitly as illustrated here. Even with this very literal XML input, the variable loaded is always FALSE. Any ideas why it won't work?
    Thanks - Bill

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: LoadXML Fails

    Hi

    You have a random bracket in your xml string, have you tried removing it?

    You can add code tags like this :
    Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

  3. #3
    Registered User
    Join Date
    10-03-2012
    Location
    Colorado
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: LoadXML Fails

    ha ha -- thanks, Kyle -- yes, that did the trick. It also pointed out a problem in my XML file. My XML file had the usual preamble, e.g.

    Please Login or Register  to view this content.
    I discovered that LoadXML would then return True on this file once I removed this preamble and left the bare well-formed XML. Why doesn't LoadXML just ignore this stuff?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1