Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Problem creating XML from scratch with MSXML and VB 6

From: Martin Honnen <mahotrash@-----.-->
To: NULL
Date: 7/1/2005 3:31:00 PM

WHoit wrote:

> I'm trying to create an xml file from scratch using MSXML and VB 6.
> The result I'm after is this:
> <myApp xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
> xsi:noNamespaceSchemaLocation="Schemas\mySchema.xsd">
> 
> Using this code:
> Set tmpXnode = xmlprs.createNode(NODE_ELEMENT, "myApp", "")
> Set tmpAnode = xmlprs.createNode(NODE_ATTRIBUTE, 
> "xsi:noNamespaceSchemaLocation", "xsi")
> tmpAnode.nodeTypedValue = "Schemas\mySchema.xsd"
> tmpXnode.Attributes.setNamedItem tmpAnode
> 
> I get this:
> <myApp xmlns:xsi="xsi" xsi:noNamespaceSchemaLocation="Schemas\mySchema.xsd">

Here is a VBScript example using the proper arguments to createNode:

Dim XmlDocument, Element, Attribute
Set XmlDocument = WScript.CreateObject("Msxml2.DOMDocument.4.0")
Set Element = XmlDocument.createElement("myApp")
Set Attribute = XmlDocument.createNode(2, "xmlns:xsi", 
"http://www.w3.org/2000/xmlns/")
Attribute.nodeValue = "http://www.w3.org/2001/XMLSchema-instance"
Element.setAttributeNode Attribute
Set Attribute = XmlDocument.createNode(2, 
"xsi:noNamespaceSchemaLocation", 
"http://www.w3.org/2001/XMLSchema-instance")
Attribute.nodeValue = "Schemas\mySchema.xsd"
Element.setAttributeNode Attribute
XmlDocument.appendChild Element
WScript.Echo XmlDocument.xml

Watch out for line breaks inserted by the news agent.
-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent