Link to home
Start Free TrialLog in
Avatar of Evan Cutler
Evan CutlerFlag for United States of America

asked on

VBScript to XML

EE Gods...
If you look below, the attribute "xmlns" shows up in all of my tags.
I only want it in two of them, and be ignored on the rest.
I cannot use namespaces, ie. xmlns:cc as this makes the SOAP service fail.
I do not have control of the service.  it is the webservice called "ConstantContact"

help?

<entry xmlns="http://www.w3.org/2005/Atom">
  <title xmlns="" type="text"/>
  <updated xmlns="">1/4/2010</updated>
  <author xmlns=""/>
  <id xmlns="">data:,none</id>
  <summary xmlns="" type="text">Contact</summary>
  <content xmlns="" type="application/vnd.ctct+xml">
    <contact xmlns="http://ws.constantcontact.com/ns/1.0/">
      <EmailAddress xmlns="">abc@yahoo.com</EmailAddress>
      <Name xmlns="">John Smith</Name>
      <OptInSource xmlns="">ACTION_BY_CUSTOMER</OptInSource>
      <ContactLists xmlns="">
        <ContactList id="https://api.constantcontact.com/ws/customers/AIDSRESEARCH/lists/5"/>
      </ContactLists>
    </contact>
  </content>
</entry>
Set objDom = Server.CreateObject("Msxml2.DOMDocument.3.0")
 Set objRoot = objDom.createElement("entry")
 Set objAttrib = objDom.createAttribute("xmlns")
 objAttrib.text = "http://www.w3.org/2005/Atom"
 objRoot.setAttributeNode objAttrib
 objDom.appendChild objRoot
 
 Set objTitle = objDom.createElement("title")
 Set objAttrib = objDom.createAttribute("type")
 objAttrib.text = "text"
 objTitle.setAttributeNode objAttrib
 objRoot.appendChild objTitle
 
 Set objUpdated = objDom.createElement("updated")
 objUpdated.text = Date()
 objRoot.appendChild objUpdated
 Set objChild = objDom.createElement("author")
 objRoot.appendChild objChild
 
 Set objId = objDom.createElement("id")
 objId.text = "data:,none"
 objRoot.appendChild objId

 Set objSummary = objDom.createElement("summary")
 Set objAttrib = objDom.createAttribute("type")
 objAttrib.text = "text"
 objSummary.setAttributeNode objAttrib
 objSummary.text = "Contact"
 objRoot.appendChild objSummary
 
 Dim content
 Set content = objDom.createElement("content")
 Set objAttrib = objDom.createAttribute("type")
 objAttrib.text = "application/vnd.ctct+xml"
 content.setAttributeNode objAttrib
 objRoot.appendChild content
 
 Dim contact
 Set contact = objDom.createElement("contact")
 Set objAttrib = objDom.createAttribute("xmlns")
 objAttrib.text = "http://ws.constantcontact.com/ns/1.0/"
 contact.setAttributeNode objAttrib
 content.appendChild contact

 
 Dim contactinfo
 Set contactinfo = objDom.createElement("EmailAddress")
 contactinfo.text = "abc@yahoo.com"
 contact.appendChild contactinfo
 
 Set contactinfo = objDom.createElement("Name")
 contactinfo.text = "John Smith"
 contact.appendChild contactinfo

 Set contactinfo = objDom.createElement("OptInSource")
 contactinfo.text = "ACTION_BY_CUSTOMER"
 contact.appendChild contactinfo
 
 Dim ContactLists
 Set ContactLists = objDom.createElement("ContactLists")
 contact.appendChild ContactLists
 
 Dim ContactList
 Set ContactList = objDom.createElement("ContactList")
 Set objAttrib = objDom.createAttribute("id")
 objAttrib.text = "https://api.constantcontact.com/ws/customers/" & UN & "/lists/5"
 ContactList.setAttributeNode objAttrib
 ContactLists.appendChild ContactList
 
  objDom.Save server.MapPath("App_Data\MyXMLDoc.xml")

Open in new window

Avatar of _Stilgar_
_Stilgar_
Flag of Israel image

As weird as it may sound, I would rather use plain string concatenation to create XMLs in ASP Classic. It is faster, ligther, and  you have much more control over it. Try that and see for yourself...
ASKER CERTIFIED SOLUTION
Avatar of PaulHews
PaulHews
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Evan Cutler

ASKER

Paul,
Thanks for the info.  Does this remove the "xmlns" from the child entries?
<summary xmlns="" type="text">Contact</summary>
  <content xmlns="" type="application/vnd.ctct+xml">


I don't want them there.  I only want them in specific tags.
YOU ARE AWESOME!!!!

Thank you so much...That worked perfectly.