Solved

XML - One Root Node

Posted on 2007-03-21
16
1,462 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

744 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

12 Experts available now in Live!

Get 1:1 Help Now