Evan Cutler
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</summa ry>
<content xmlns="" type="application/vnd.ctct +xml">
<contact xmlns="http://ws.constantcontact.com/ns/1.0/">
<EmailAddress xmlns="">abc@yahoo.com</Em ailAddress >
<Name xmlns="">John Smith</Name>
<OptInSource xmlns="">ACTION_BY_CUSTOME R</OptInSo urce>
<ContactLists xmlns="">
<ContactList id="https://api.constantcontact.com/ws/customers/AIDSRESEARCH/lists/5"/>
</ContactLists>
</contact>
</content>
</entry>
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</summa
<content xmlns="" type="application/vnd.ctct
<contact xmlns="http://ws.constantcontact.com/ns/1.0/">
<EmailAddress xmlns="">abc@yahoo.com</Em
<Name xmlns="">John Smith</Name>
<OptInSource xmlns="">ACTION_BY_CUSTOME
<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")
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Paul,
Thanks for the info. Does this remove the "xmlns" from the child entries?
<summary xmlns="" type="text">Contact</summa ry>
<content xmlns="" type="application/vnd.ctct +xml">
I don't want them there. I only want them in specific tags.
Thanks for the info. Does this remove the "xmlns" from the child entries?
<summary xmlns="" type="text">Contact</summa
<content xmlns="" type="application/vnd.ctct
I don't want them there. I only want them in specific tags.
Yes
ASKER
YOU ARE AWESOME!!!!
Thank you so much...That worked perfectly.
Thank you so much...That worked perfectly.