Importing third party XML data into MS Visio

I type text into shapes in Visio drawings derived from Templates. Now I want to add automation,  by importing text automatically from various third party XMLs. Can I and ought I import the data fields of the 3rd party into MSOffice XML derived from my drawing template? I use Visio 2010 Premium.

This would involve a learning curve on my part. I am aware that third party XML should be established as well formed, and they will not comply with the MS schema.

Can you recommend procedures/applications whereby I can:
- Select, for each relevant data field in Visio MSOffice XML, which data field should be imported from the third party XML?
- Make a sensible shell in vba to automate the import process, so that a series of third party XML specifications of the same structure but different content can be imported into different instances of a Visio template.

If available, on the grounds of cost, freeware / vba code would be an attractive first step, to gain a working model in the first instance. However, a commercial application would be of interest if it can be used 'out of the box'.


Who is Participating?

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

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.

Kelvin4Author Commented:
Thanks for your advice:

-Sample of third Party XML is attached in the file. Reference to XML Schema is included in <MyDoc>.  I had thought that XML validation would be carried out in Excel. The size of the third party XML file could be much larger than the demo of 28 lines. For example there are four elements: "Text1 identifier" ... "Text4 identifier", and could be many more. But the overall complexity of the file is not great.

- Visio MSOffice XML  I don’t have a sample of this run off and annotated at present. Well over 95% of the data in the Visio XML file will not be copied from the third party XML, but generated de novo from within the Visio file.

- DATA IMPORTED from Third Party file will be Text and numbers, but mainly text.

Text is not currently limited in length, but I don’t anticipate lengths in excess of 1500 characters.

Some text will contain HTML tags. I can parse those tags so that the formatting they specify is viewable in Visio.shape.text, by creating the appropriate data in the shape character file (in the shapesheet character section).

I hope this is useful information.
I looked at the XML in the Word document, using XML Notepad (a handy free tool from Microsoft).

I had to clean it up in a few places, specifically:
* Word smart quotes used instead of Chr(34) ASCII quote characters a couple of times
* Missing space before xsi:schemaLocation= and method1=
* space in closing tag </rInput> between the slash and the "r"

Cleaned up version of the code:
<MyDoc xmlns="Thisxmlns" xmlns:xsi="ThisXMLSchema-instance" xsi:schemaLocation="ThisSchema.xsd" identifier="MyID" title="MyTitle" method1="false" time="false">
  <rInput identifier="myInput" type="single" baseType="identifier">
  <output identifier="myOutput" type="single" dataType="integer">
    <p>Look at the text in the picture.</p>
      <img src="images/myGraphic.png" alt="image title" />
    <theTexts responseIdentifier="RESPONSE" param1="true" param2="1">
      <prompt>What does it say?</prompt>
      <Text1 identifier="myTextIdentifier1">MyText1</Text1>
      <Text2 identifier="myTextIdentifier2">MyText2</Text2>
      <Text3 identifier="myTextIdentifier3">MyText3</Text3>
      <Text4 identifier="myTextIdentifier4">MyText4</Text4>
  <VisioProcessing template="ThisVisioTemplate" />

Open in new window

If you are editing this XML, use XML Notepad, Notepad, or some editor that will will not introduce changes that invalidate/malform the XML.
Once the XML was 'cleaned' I was able to open it with Excel without any problems.

I would like to see the XML without your editing it.  Please upload your XML file.
The 7 Worst Nightmares of a Sysadmin

Fear not! To defend your business’ IT systems we’re going to shine a light on the seven most sinister terrors that haunt sysadmins. That way you can be sure there’s nothing in your stack waiting to go bump in the night.

Kelvin4Author Commented:
Thank you for the trouble taken; my effort to simplify the text has been unhelpful. Attached is the original, but I added spaces as you did, as XML Notepad reported the lack of spaces that you identified.

XML Notepad also reported the use of incorrect quote marks, but I could not identify them.

The material comes from the qti standards for setting computer-based questions, and is a useful place to start experimenting with the import of third party XML.

I hope this is helpful
The vendor is producing malformed XML.  The sample you posted contained the following incorrect closing tag:
</ responseDeclaration>

Open in new window

Such errors can be easily fixed by some simple editing (manual or programmatic), replacing all "</ " with "</" until no more are found in the file.

I didn't get any other error messages when opening the file with XML Notepad.  It did take a long time to open the file because of the xmlns: links.  I assume your open times are much faster.
Kelvin4Author Commented:
Yrs, thanks, the corrected XML file opened immediately in XML Notepad.
You should contact the vendor and let them know of this problem.

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
Kelvin4Author Commented:
Thanks. You have looked at my files, corrected them, got me started  with XML Notepad, and aware of malformed third party XML. I will sign this question off as Solved and ask a second question, to address the problem of importing selected well-formed third party XML data into certain data fields of MS Office XML for Visio.

I have run off some XML from a small visio test file, with one data field of interest. The XML data field into which I want to export third party data is visible in XML NotePad.  

If I forward these in a new question, would you be in a position to help me tackle the data transfer method?

Kelvin4Author Commented:
Thanks for the start. Kelvin

>>If I forward these in a new question...
I'm currently monitoring http:/Q_27661631.htm
However, I don't have Visio, so I can't help you as a subject matter expert with that part of your problem.
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
Microsoft Visio

From novice to tech pro — start learning today.