[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

XML - One Root Node

Posted on 2007-03-21
16
Medium Priority
?
1,666 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
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.

 
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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

650 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