Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MathCAD 13 Document and XMLDocument.Loadxml

Status
Not open for further replies.

fawkes

Technical User
Sep 12, 2003
343
GB
I'm trying to load a MathCAD 13 document into an xmldocument in Visual Studio 2005

Code:
        Dim xmlDoc As New Xml.XmlDocument

        'Load the xml document
        xmlDoc.LoadXml("test1.xmcd")

But I get the follwing error message:

Data at the root level is invalid. Line 1, position 1.

The first lines of the xml document are:

Code:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?validation-md5-digest a38d3955c9cd5d0521007998f5a2d587?>
<worksheet version="2.0.2" xmlns="[URL unfurl="true"]http://schemas.mathsoft.com/worksheet20"[/URL] xmlns:xsi="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance"[/URL] xmlns:ws="[URL unfurl="true"]http://schemas.mathsoft.com/worksheet20"[/URL] xmlns:ml="[URL unfurl="true"]http://schemas.mathsoft.com/math20"[/URL] xmlns:u="[URL unfurl="true"]http://schemas.mathsoft.com/units10"[/URL] xmlns:p="[URL unfurl="true"]http://schemas.mathsoft.com/provenance10">[/URL]


When I just use
Code:
xmlDoc.Load("test1.xmcd")
I struggle to use
Code:
xmldoc.SelectNodes("worksheet")

I don't know if it's related but I seem to think so.

Any ideas?
 
OK,

I know where I've made one mistake, I should have used

Code:
xmlDoc.Load("test1.xmcd")

and not

Code:
xmlDoc.Loadxml("test1.xmcd")

The LoadXML method is looking for xml text.

I still need help on the select nodes method though
 
I have it, it's to do with namespaces

Code:
Dim nsmgr As Xml.XmlNamespaceManager = New Xml.XmlNamespaceManager(xmlDoc.NameTable)
        nsmgr.AddNamespace("ws", "[URL unfurl="true"]http://schemas.mathsoft.com/worksheet20")[/URL]
        nsmgr.AddNamespace("", "[URL unfurl="true"]http://schemas.mathsoft.com/worksheet20")[/URL]
        nsmgr.AddNamespace("ml", "[URL unfurl="true"]http://schemas.mathsoft.com/math20")[/URL]
        nsmgr.AddNamespace("u", "[URL unfurl="true"]http://schemas.mathsoft.com/units10")[/URL]
        nsmgr.AddNamespace("p", "[URL unfurl="true"]http://schemas.mathsoft.com/provenance10")[/URL]

        Dim wkNode As Xml.XmlNode
        For Each wkNode In xmlDoc.SelectNodes("ws:worksheet", nsmgr)
          '... Code here ...
        Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top