Skip to main content
Inspiring
August 13, 2010
Question

Help getting value from xml node

  • August 13, 2010
  • 2 replies
  • 3124 views

I need help in getting the value of the following xml node called MemberInformation's Last_Updated's value (see below)

I got all the values such as the id, addr1,addr2,addr3,addr4, city,state,zip and country but can get the Lat_Updated value back

I got the id's values back but why not last_updated values??? do I need a certain tehnique to get the second nodes of MemberInformation?

Please help!

Here is how I invoke my xml (see the xml below my cfinvoke tags):

<cfinvoke webservice="https://someurl.asmx?wsdl" method="GetMembersChangedSince" returnvariable="result4">

     <cfinvokeargument name="login" value="xxxxxxxxxxxxxx">

     <cfinvokeargument name="password" value="xxxxxxx">

     <cfinvokeargument name="columns" value="id,addr1,addr2,addr3,addr4,city,state,zip,country,last_updated">  <------?????

                                  

                                  

                                 

     <cfinvokeargument name="changedColumns" value="">

     <cfinvokeargument name="changedSince" value="2010-07-21">

     <cfinvokeargument name="includeNonMembers" value="TRUE">

     <cfinvokeargument name="includeBlankIds" value="FALSE">

     <cfinvokeargument name="filter" value="[id] LIKE '0%'">

</cfinvoke>

<?xml version="1.0" encoding="utf-8" ?>
- <ArrayOfMemberInformation>
- <MemberInformation Constituent_Id="0001342752" Last_Updated="2010-08-01T10:37:44">
     <Column Name="ID" Value="0001342752" />
    <Column Name="Addr1" Value="265 Light Drive" />
      <Column Name="Addr2" Value="" />
      <Column Name="Addr3" Value="" />
      <Column Name="Addr4" Value="" />
      <Column Name="City" Value="Stevensville" />
      <Column Name="State" Value="MD" />
      <Column Name="Zip" Value="21666" />
      <Column Name="Country" Value="" />
</MemberInformation>
- <MemberInformation Constituent_Id="0035483809" Last_Updated="2010-08-02T14:45:34">
      <Column Name="ID" Value="0035483809" />
      <Column Name="Addr1" Value="Brunngasse 30" />
      <Column Name="Addr2" Value="" />
      <Column Name="Addr3" Value="" />
      <Column Name="Addr4" Value="Reinach 40012" />
      <Column Name="City" Value="" />
      <Column Name="State" Value="" />
      <Column Name="Zip" Value="" />
      <Column Name="Country" Value="Switzerland" />
</MemberInformation>
</ArrayOfMemberInformation>
This topic has been closed for replies.

2 replies

Inspiring
August 14, 2010

OK.  But what have you yourself tried so far?

--

Adam

Inspiring
August 16, 2010

This is how I tried so far:

(here is the wsdl file : https://admin.imodules.com/ws_20/generalquery.asmx?wsdl )

1. Invoking the web services using cfinvoke as written on my first post

2. My CFINVOKE returns an Array, Here is what I did to this array:

    <CFSET MemberInfo_2 = result4.getMemberInformation()>

    <CFIF IsDefined("MemberInfo_2")>

        <CFSET Call_DateSince_2(#MemberInfo_2#,'#url.changesince#')>

    </CFIF>

3. Looping each array element and calling getColumn

<CFFUNCTION name="Call_DateSince_2" hint="Processing Original address step 1">

  <cfargument name="Arr_MemberInfo_2" type="Array" required="true">

  <cfargument name="DateChangeType_2" type="String" required="true">

  <cfloop from="1" to="#arraylen(arguments.Arr_MemberInfo_2)#" index="i">

    <CFSET GetAddress(arguments.Arr_MemberInfo_2.getColumn(),i,arguments.DateChangeType_2)>

  </cfloop>

</CFFUNCTION>

4. I'm able to update my addr. table with all the columns EXCEPT last_updated

<CFFUNCTION name="GetAddress" hint="Processing Original address step 2">

  <cfargument name="MemberInfoArray" type="Array" required="true">

  <cfargument name="SeqId" type="Numeric" required="true">

  <cfargument name="DateChangeType" type="String" required="true">

  <cfset st_OrigAddr = StructNew()>

<cfloop from="1" to="#arraylen(arguments.MemberInfoArray)#" index="j">

  <cfset st_OrigAddr["#arguments.MemberInfoArray.getName()#"]="#arguments.MemberInfoArray.getValue()#">

</cfloop>

<cfquery name="UpdateAddrTable"datasource="AddrDB">

  UPDATE AddrTable

  SET addr1 = <cfqueryparam cfsqltype="cf_sql_varchar" value="#st_OrigAddr["addr1"]#">,

  addr2 =

<cfqueryparam cfsqltype="cf_sql_varchar" value="#st_OrigAddr["addr2"]#">,

  addr3 =

<cfqueryparam cfsqltype="cf_sql_varchar" value="#st_OrigAddr["addr3"]#">,

  addr4 =

<cfqueryparam cfsqltype="cf_sql_varchar" value="#st_OrigAddr["addr4"]#">,

  city =

<cfqueryparam cfsqltype="cf_sql_varchar" value="#st_OrigAddr["city"]#">,

  state =

<cfqueryparam cfsqltype="cf_sql_varchar" value="#st_OrigAddr["state"]#">,

  zip =

<cfqueryparam cfsqltype="cf_sql_varchar" value="#st_OrigAddr["zip"]#">,

  country =

<cfqueryparam cfsqltype="cf_sql_varchar" value="#st_OrigAddr["country"]#">,

  busaddr1 =

<cfqueryparam cfsqltype="cf_sql_varchar" value="#st_OrigAddr["busaddr1"]#">,

  busaddr2 =

<cfqueryparam cfsqltype="cf_sql_varchar" value="#st_OrigAddr["busaddr2"]#">,

  busaddr3 =

<cfqueryparam cfsqltype="cf_sql_varchar" value="#st_OrigAddr["busaddr3"]#">,

  buscity =

<cfqueryparam cfsqltype="cf_sql_varchar" value="#st_OrigAddr["buscity"]#">,

  busst =

<cfqueryparam cfsqltype="cf_sql_varchar" value="#st_OrigAddr["busst"]#">,

  buszip =

<cfqueryparam cfsqltype="cf_sql_varchar" value="#st_OrigAddr["buszip"]#">,

  buscountry =

<cfqueryparam cfsqltype="cf_sql_varchar" value="#st_OrigAddr["buscountry"]#">

  WHERE id = <cfqueryparam cfsqltype="cf_sql_varchar" value="#st_OrigAddr["id"]#">

  </cfquery>

</CFFUNCTION>

Inspiring
August 16, 2010

Yikes.  Too much code!

The question you're asking is how to get a value from an XML node.  You don't need to post functions & queries and that sort of stuff... just start with some XML (you've posted that), and the code you have tried to use to get your value from it.  Factor it out of all the other stuff... there's no point thinking about that until you are clear on how to get the node value out of the XML.

Your code should be something like:

<cfxml variable="x">

<!--- xml in here --->

</cfxml>

<cfset someVariable = [some code you have used to get your node value]>

(it might be more than one line of code, but you get my drift)

Once you're clear on what  [some code you have used to get your node value] is, then you can reintegrate it into the rest of the code.

You are trying to do too much @ once here, I think.

--

Adam

Inspiring
August 14, 2010

This article http://www.adobe.com/livedocs/coldfusion/6.1/htmldocs/xml34.htm will show you some of the syntax you'll have to use.