Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1721
  • Last Modified:

XML - One Root Node

I'm using VB6 and Microsoft XML 4.0

I have an XML string that I am trying to load into the DOMDocument40.

It is returning "False", meaning the load failed.  I look at XMLDoc.Validate.reason and get the following:
Validate failed because the document does not contain exactly one root node.

Unfortunately, due to company security, I can't post the XML.  However, when I view the xml string in IE, I can see only one root node.

If I use XML 2.0 I have no problem.

Any ideas what might be wrong?
0
Clif
Asked:
Clif
  • 7
  • 5
  • 3
  • +1
1 Solution
 
BobSiemensCommented:
Load it (i.e. just double click it) in an IE browser.  You may have an extra </root> tag in the middle of the file.
0
 
BobSiemensCommented:
<<<However, when I view the xml string in IE, I can see only one root node.>>>

Oops, didn't see this

0
 
BobSiemensCommented:
You may have special characters that are causing problems.  Remove all non ascii characters from the xml file and attempt the import again.

Here's another reason this may occur: http://support.microsoft.com/kb/315358

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ClifAuthor Commented:
There are no non-ascii characters.  Thanks for the link, but it didn't solve my problem.

0
 
programmer1024Commented:
It is difficult to diagnose the xml conflict without seeing xml. Can you substitute the sensitive tags with different names, just so we can see what issue you are seeing/not seeing?
0
 
ClifAuthor Commented:
Ok, the aspect of this question is going to change a bit.

Apparently the problem is with the schema (or, more specifically, the lack thereof).

Perhaps a little bit of background...
Due to security issues, we are not using a webservice.  The xml is being delivered through http via a post call (don't ask, I don't understand why that's more secure either).

In conjunction with this question, I also asked the supplier of the xml about my issue.  The general consensus is that it has to do with the schema.  The developer who is providing the xml asked if MSXML4.0 allows for a bypass of the schema validation , or if I can load the schema text (like I am loading the xml string).

So, is this possible?
0
 
ClifAuthor Commented:
programmer1024,
Sorry, I was typing when you posted.  Hopefully the new information will help.
0
 
Anthony PerkinsCommented:
>> I look at XMLDoc.Validate.reason and get the following:<<
You are going about it the wrong way.

You do not use the Validate method to find out the error you use:
XmlDoc.ParseError.reason

Validate does not apply when you do not use a schema.

>>If I use XML 2.0 I have no problem.<<
Not surprising.  MSXml 2.0 did not support Xml Schema
0
 
Anthony PerkinsCommented:
In other words your code should read:
If XmlDoc.Load(..) Then
   ' Your code goes here
Else      ' Oops.  Houston we have a problem!
   With XmlDoc.ParseError
   Debug.Print .filepos, .line, .linepos, .reason, .srcText, .errorCode
End If
0
 
Anthony PerkinsCommented:
Actually (and sorry for the multiple posts) in your case this:
If XmlDoc.Load(..) Then

Should read:
If XmlDoc.loadXML(..) Then
0
 
ClifAuthor Commented:
Thanks, it's now telling me that a specific attribute is invalid.  I can now send it back to the source and find out what they say about it.

Does "xsi:nil" mean anything to y'all?
0
 
ClifAuthor Commented:
One thing I noticed, not sure if it means anything...

srcText doesn't contain the entire XML.  It only contains 2000 characters (2007 with spaces).
0
 
Anthony PerkinsCommented:
>>Does "xsi:nil" mean anything to y'all?<<
That is a namespace.

>>It only contains 2000 characters (2007 with spaces).<<
Than I would suspect they are using ODBC to extract the Xml data.
0
 
ClifAuthor Commented:
I receive the *total* xml from the post.  However, when I LoadXML into MSXML4.0, the srcText only reports the 2000/7 characters.  I'm not sure what ODBC has to do with that.

0
 
Anthony PerkinsCommented:
>>However, when I LoadXML into MSXML4.0, the srcText only reports the 2000/7 characters<<
It probably only includes the problem text and not the whole document.

>>I'm not sure what ODBC has to do with that.<<
If that is the case, than nothing.  It was a WAG.
0
 
ClifAuthor Commented:
Our XML source team has fixed the problem.  It was, indeed, a problem with the attribute.

Thanks to acperkins for pointing me in the right direction with retrieving the actual error.

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 7
  • 5
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now