Solved

XML - One Root Node

Posted on 2007-03-21
16
1,568 Views
Last Modified: 2010-05-18
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
Comment
Question by:Clif
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
  • 3
  • +1
16 Comments
 
LVL 10

Expert Comment

by:BobSiemens
ID: 18766798
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
 
LVL 10

Expert Comment

by:BobSiemens
ID: 18766845
<<<However, when I view the xml string in IE, I can see only one root node.>>>

Oops, didn't see this

0
 
LVL 10

Expert Comment

by:BobSiemens
ID: 18766910
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
Technology Partners: 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!

 
LVL 10

Author Comment

by:Clif
ID: 18767024
There are no non-ascii characters.  Thanks for the link, but it didn't solve my problem.

0
 
LVL 4

Expert Comment

by:programmer1024
ID: 18771634
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
 
LVL 10

Author Comment

by:Clif
ID: 18771903
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
 
LVL 10

Author Comment

by:Clif
ID: 18771927
programmer1024,
Sorry, I was typing when you posted.  Hopefully the new information will help.
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 500 total points
ID: 18777643
>> 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
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 18777652
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
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 18777658
Actually (and sorry for the multiple posts) in your case this:
If XmlDoc.Load(..) Then

Should read:
If XmlDoc.loadXML(..) Then
0
 
LVL 10

Author Comment

by:Clif
ID: 18779072
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
 
LVL 10

Author Comment

by:Clif
ID: 18779675
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
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 18780596
>>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
 
LVL 10

Author Comment

by:Clif
ID: 18780645
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
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 18780883
>>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
 
LVL 10

Author Comment

by:Clif
ID: 18781390
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question