Can't find Node sqlxmlCommand

Hi Experts,

I have an issue with sqlXMLCommand, can't find a Node in the schema.
I am running VB.Net Windows Forms App and the XSD is on the SQL server, sending it full UNC path.

Error: "XPath: unable to find /root in the schema."

I have attached the XSD file, but I am sure it is something to do with find it, rather than the file itself.

Related Resource:
http://sqlxml.org/faqs.aspx?faq=50

Cheers

C
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        ' Load XML data from SQL Server directly into a DataSet
        Dim strConn As String = "Provider=SQLNCLI;Data Source=xxxxx;Initial Catalog=Dev;User Id=xxxx;Password=xxxxx;"

        ' Define the XML command
        Dim cmd As SqlXmlCommand = New SqlXmlCommand(strConn)
        Dim strmReader As StreamReader

        cmd.RootTag = "Root"
        cmd.CommandText = "InspectionWorkStatus"
        cmd.CommandType = SqlXmlCommandType.XPath
        cmd.SchemaPath = Me.txtSQLXSDPath.Text.ToString
        cmd.Namespaces = "xmlns:vms='http://www.xxxxxx.com.au/vms/v0.5'"
        cmd.ClientSideXml = True

        Dim ms As MemoryStream = New MemoryStream()

        cmd.ExecuteToStream(ms)

        strmReader = New StreamReader(ms)

        Dim strXML As String = strmReader.ReadToEnd
        Dim xDoc As New XmlDocument

        xDoc.LoadXml(strXML)

        Dim strTestFileName As String = ""
        strTestFileName = "S:\DB CreationTools\Testing\tst_" & Format(Now(), "hh_mm_ddmmyyyy") & ".xml"
        xDoc.Save(strTestFileName)
        Debug.Print(strTestFileName)

Open in new window

forExperts.xsd
LVL 1
Craig LambieAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

cyberkiwiCommented:
The schema does not contain anything named "Root".
You want the RootTag to be "WorkPackage"?
Craig LambieAuthor Commented:
in XML validated against the Schema the root node is actually "InspectionWorkStatus" of which I have tried in that property already.

I am not sure what the problem is, but I thought the RootTag property was simply anything you wanted it to be.  On the example I found that works with Northwind it is just that.
http://www.developer.com/xml/article.php/3341881/Using-the-SQLXML-Managed-Classes


Craig LambieAuthor Commented:
The answer is actually the namespace.

http://msdn.microsoft.com/en-us/library/aa258639(SQL.80).aspx

I changed the target namespace to be the correct Namespace, and then added the prefix to the code, this way I actually could use the Xpath Query engine and get it to work.
I then wrote some code to remove the BS root element the sqlxmlcommand adds as it is just annoying and in effective (for my uses)

Now I have completely valid XML from my annotated XSD file, totally query-able.


cmd.RootTag = "root"
            cmd.CommandText = "vms:InspectionWorkStatus[xxxx/xxxx='xxxx']"
            cmd.CommandType = SqlXmlCommandType.XPath
            cmd.SchemaPath = Me.txtSQLXSDPath.Text.ToString
            cmd.Namespaces = "xmlns:vms='http://www.xxxx.com.au/vms/v0.5' xmlns='http://www.w3.org/2001/XMLSchema'"
            cmd.ClientSideXml = True

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
XML

From novice to tech pro — start learning today.