![]() |
Telelogic System Architect (steve huntington) | ![]() |
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 |
![]() |
![]()
|
![]() |
|
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. |
|
![]() |
|
![]() |
|
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.
(Edited 6/16/06 to correct code) Edited: 16-Jun-2006 at 19:07 by Andrea Heithoff |
|
![]() |
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
Andrea, Re-reading through your code, I would use a WriteLine versus continually concatenating onto a string variable and then writing. |
|
![]() |
|
![]() |
|
Your other option is to use the MSXML object. Example: Set xmlDoc = CreateObject("Microsoft.XMLDOM") 'Method parameters 'Create document Set fruitFarmNode = xmlDoc.createNode("element", "FruitFarm", "") Set fruitNode = xmlDoc.createNode("element", "Fruit", "") Set fruitNode = xmlDoc.createNode("element", "Fruit", "") Set fruitNode = xmlDoc.createNode("element", "Fruit", "") xmlDoc.appendChild(fruitFarmNode) Edited: 27-Jul-2006 at 02:43 by Duane Hennessy |
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.