Solved

XML - One Root Node

Posted on 2007-03-21
16
1,503 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
  • 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
 
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
XML to SQL Table using c# 5 57
Create XML 5 47
Using an encrypted  value to decrypt and display contents in vb6 9 50
XSL FO - text wrapping and empty spaces 1 26
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

863 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now