Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic System Architect (steve huntington)
Decrease font size
Increase font size
Topic Title: VBA to create XML file
Topic Summary: what application object do I use?
Created On: 13-Jun-2006 16:22
Status: Read Only
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 13-Jun-2006 16:22
User is offline View Users Profile Print this message


Andrea Heithoff

Posts: 33
Joined: 15-Aug-2005

I'm trying to generate XML based on a property instead of selecting each definition from the browser.  My problem is in creating the correct application object that will properly create an xml file.  If anyone has experience in or an example of generating an XML file using VBA I'd appreciate the help.

Report this to a Moderator Report this to a Moderator
 13-Jun-2006 18:57
User is offline View Users Profile Print this message


Andrea Heithoff

Posts: 33
Joined: 15-Aug-2005

Nothing like answering my own question...  I discovered the Microsoft XML version 2.0 library, added as a reference from the Tools menu, which enabled me to create an object of type DOMDocument.  I had to create a single string from the SADefinitionObject.XML attributes of what I wanted, then use the DOMDocument.loadXML in order to take advantage of the tags stored in SADef.XML property.

Does anyone know a better method that doesn't rely on a string?  I know there's a lot of room in the string variable, but I'm not sure it can hold everything I'll need.  I'm hoping to take advantage of the XML property.

 

(Edited 6/16/06 to correct code)



Edited: 16-Jun-2006 at 19:07 by Andrea Heithoff
Report this to a Moderator Report this to a Moderator
 20-Jul-2006 23:31
User is offline View Users Profile Print this message


William Wimsatt

Posts: 17
Joined: 7-Nov-2005

Andrea,

I have been exporting some very large SAObjects and have had any problems with strings. Attached is some code I have been working with to export XML. I too want to have file without having to use the menus. The code attached is somewhat test code. It creates two files for each object in the repository. One file will contain the XML attribute for object. The other file is a custom XML file.

The problem I am having is creating the appropriate object links. The XML Export function will create a node of type SALink. I do not have that generated at this time. The XML attribute does not contain this link. I just need to add the appropriate call into the procedure to generate this information.

I am parsing ListOfs in this code, as well.

Anyone have any thoughts on getting the links? The GetRelatedObjects method is the key here and I am loathe to think I have to iterate through all of the relationship types to get what I need.

Bill

Edited: 21-Jul-2006 at 16:43 by William Wimsatt
Report this to a Moderator Report this to a Moderator
 25-Jul-2006 18:45
User is offline View Users Profile Print this message


William Wimsatt

Posts: 17
Joined: 7-Nov-2005

Andrea,

Re-reading through your code, I would use a WriteLine versus continually concatenating onto a string variable and then writing.

BTW, do note that the XML property will not get everything for the object. It will not have relationships to other items (SALinks if you export the definition) and it does not have some properties such as ILAC settings.

I have created a VBA script that outputs everything and I am now creating a new .Net program to create a web service for accessing the information from SA. Let me know if you are interested.

Bill

Report this to a Moderator Report this to a Moderator
 27-Jul-2006 02:39
User is offline View Users Profile Print this message


Duane Hennessy

Posts: 112
Joined: 18-May-2006

Your other option is to use the MSXML object. Example:

Dim xmlDoc as Object
Dim root as Object, fruitNode as Object, fruitFarmNode as Object


Set xmlDoc = CreateObject("Microsoft.XMLDOM")


'Method parameters
'.createNode(Type, name, namespaceURI)


'Create document
Set root = xmlDoc.createNode("element", "MyRootNode", "")
xmlDoc.appendChild (root)


Set fruitFarmNode = xmlDoc.createNode("element", "FruitFarm", "")


Set fruitNode = xmlDoc.createNode("element", "Fruit", "")
fruitNode.Text="Banana"
fruitFarmNode.appendChild(fruitNode)


Set fruitNode = xmlDoc.createNode("element", "Fruit", "")
fruitNode.Text="Strawberry"
fruitFarmNode.appendChild(fruitNode)


Set fruitNode = xmlDoc.createNode("element", "Fruit", "")
fruitNode.Text="Gooseberry"
fruitFarmNode.appendChild(fruitNode)


xmlDoc.appendChild(fruitFarmNode)
xmlDoc.save ("c:\TheFruitFarm.xml")

Some handy links:
'Info and specs etc: http://windowssdk.msdn.microsoft.com/en-us/library/ms763742.aspx
'See http://www.devguru.com/features/tutorials/usingxml/usingxml.htm
'See http://dhillman.com/theplace/xml/xmldomtech.htm
'See http://www.topxml.com/code/default.asp?p=3&id=v20010807155806&ms=20&l=dataisland&sw=categ

You'll have to add the <?xml version="1.0"?> etc line yourself to the document. There might be something in the MSXML object that does this if you switch it on but I've never bothered.

Hope this helps




Edited: 27-Jul-2006 at 02:43 by Duane Hennessy
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic System Architect forum.
There are currently 1 users logged in.
The most users ever online was 16 on 30-Oct-2008 at 14:46.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.