Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Convert XML to ASP variables

Posted on 2009-07-15
3
Medium Priority
?
380 Views
Last Modified: 2013-11-18
Hi Experts

We are attempting to use the Campaign Monitor API. We can successfully retrieve information. But need advice and examples of how to turn that information into ASP variables.

Below is an example of the code that is delivered back that needs to be manipulated.

Thanks for your time.
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
        <Client.GetListsResponse xmlns="http://api.createsend.com/api/">
            <Client.GetListsResult xsi:type="ArrayOfList">
                <List>
                    <ListID>d4945449063b88ca30326b11fb2b6ef3</ListID>
                    <Name>List1</Name>
                </List>
                <List>
                    <ListID>4bc44de19a3830d5f332abd032a7da7f</ListID>
                    <Name>List2</Name>
                </List>
                <List>
                    <ListID>09c0f936874d9e132b5155082242acc3</ListID>
                    <Name>List3</Name>
                </List>
            </Client.GetListsResult>
        </Client.GetListsResponse>
    </soap:Body>
</soap:Envelope>

Open in new window

0
Comment
Question by:hnEE
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 25

Accepted Solution

by:
kevp75 earned 2000 total points
ID: 24878148
that is delivered back to you from the web service?  Usually a SOAP Envelop is sent to the service...

I guess you could process it anyways, like normal XML...

try out the below:


<%
'---------------------------------------------------------------------------------------
' The following is tested and is working @ http://manager.zipcm.com/temp/test1.asp
'---------------------------------------------------------------------------------------
tmpString = ""
tmpString = tmpString & "<?xml version=""1.0"" encoding=""utf-8""?>"
tmpString = tmpString & "<soap:Envelope xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">"
tmpString = tmpString & "    <soap:Body>"
tmpString = tmpString & "        <Client.GetListsResponse xmlns=""http://api.createsend.com/api/"">"
tmpString = tmpString & "            <Client.GetListsResult xsi:type=""ArrayOfList"">"
tmpString = tmpString & "               <List>"
tmpString = tmpString & "                    <ListID>d4945449063b88ca30326b11fb2b6ef3</ListID>"
tmpString = tmpString & "                    <Name>List1</Name>"
tmpString = tmpString & "                </List>"
tmpString = tmpString & "                <List>"
tmpString = tmpString & "                    <ListID>4bc44de19a3830d5f332abd032a7da7f</ListID>"
tmpString = tmpString & "                    <Name>List2</Name>"
tmpString = tmpString & "                </List>"
tmpString = tmpString & "                <List>"
tmpString = tmpString & "                    <ListID>09c0f936874d9e132b5155082242acc3</ListID>"
tmpString = tmpString & "                    <Name>List3</Name>"
tmpString = tmpString & "                </List>"
tmpString = tmpString & "            </Client.GetListsResult>"
tmpString = tmpString & "        </Client.GetListsResponse>"
tmpString = tmpString & "    </soap:Body>"
tmpString = tmpString & "</soap:Envelope>"
Set objXML = CreateObject("Microsoft.FreeThreadedXMLDOM")
	objXML.async = False
	boolExists = objXML.LoadXML(tmpString) '<-Change to .Load(YourFilePath)
	If boolExists Then
		Set objRoot = objXML.selectSingleNode("//Client.GetListsResult")
			ReDim ListID(objRoot.ChildNodes.Length - 1)
			ReDim Name(objRoot.ChildNodes.Length - 1)
			For i = 0 To objRoot.ChildNodes.Length - 1
				ListID(i) = objRoot.ChildNodes.Item(i).ChildNodes.Item(0).Text
				Name(i) = objRoot.ChildNodes.Item(i).ChildNodes.Item(1).Text
			Next : i = Null
		Set objRoot = Nothing
	Else
		Response.WRite("There is no respnse.")
	End If
Set objXML = Nothing
'A Test To See if we are getting the results
If IsArray(ListID) And IsArray(Name) Then
	For i = LBound(ListID) To UBound(ListID)
		Response.Write("Node: " & i & " | ListID: " & ListID(i) & " | Name: " & Name(i) & "<br />")
	Next : i = Null
End If
%>

Open in new window

0
 

Author Closing Comment

by:hnEE
ID: 31604062
Thank you very much. Hopefully, I can take your example and apply it to other parts of the API.
0
 
LVL 25

Expert Comment

by:kevp75
ID: 24915804
glad I could help
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question