×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

MathCAD 13 Document and XMLDocument.Loadxml

MathCAD 13 Document and XMLDocument.Loadxml

MathCAD 13 Document and XMLDocument.Loadxml

(OP)
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="http://schemas.mathsoft.com/worksheet20" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ws="http://schemas.mathsoft.com/worksheet20" xmlns:ml="http://schemas.mathsoft.com/math20" xmlns:u="http://schemas.mathsoft.com/units10" xmlns:p="http://schemas.mathsoft.com/provenance10">

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?

RE: MathCAD 13 Document and XMLDocument.Loadxml

(OP)
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

RE: MathCAD 13 Document and XMLDocument.Loadxml

(OP)
I have it, it's to do with namespaces

CODE


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

        Dim wkNode As Xml.XmlNode
        For Each wkNode In xmlDoc.SelectNodes("ws:worksheet", nsmgr)
          '... Code here ...
        Next

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources