cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Not applicable

Query XML after Call Web Service

I have used the GetUserProfileByName web service to retrieve a profile in XML format. I now ned to retrieve a specific piece of data from the xml.

 

A sample of the xml returned (also attached) is

 

<xml>

<PropertyData xmlns="http://microsoft.com/webservices/SharePointPortalServer/UserProfileService">

     <IsPrivacyChanged>false</IsPrivacyChanged>

false     <IsValueChanged>false</IsValueChanged>

     <Name>HomePhone</Name

Public     ><Privacy>Public</Privacy>

     <Values

          ><ValueData>

               <Value xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">250-555-1111</Value>

          </ValueData>

     </Values>

</PropertyData>

<PropertyData xmlns="http://microsoft.com/webservices/SharePointPortalServer/UserProfileService">

false     <IsPrivacyChanged>false</IsPrivacyChanged>

false     <IsValueChanged>false</IsValueChanged>

CellPhone     <Name>CellPhone</Name>

Public     <Privacy>Public</Privacy>

     <Values>

          <ValueData>

               <Value xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">250-555-2222</Value>

          </ValueData>

     </Values>

</PropertyData>

<PropertyData xmlns="http://microsoft.com/webservices/SharePointPortalServer/UserProfileService">

false     <IsPrivacyChanged>false</IsPrivacyChanged>

false     <IsValueChanged>false</IsValueChanged>

EmergencyContactPerson     <Name>EmergencyContactPerson</Name>

     <Privacy>Public</Privacy><

     Values>

          <ValueData>

               <Value xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">George Washington</Value>

          </ValueData>

     </Values>

</PropertyData>

</xml>

 

Using a Query XML I would like to extract the value of "George Washington" from the node that has Name=EmergencyContactPerson. I have tried a number of different things but have not managed to get it to work. I am running Nintex 2007.

 

Thanks

Labels: (1)
Tags (1)
0 Kudos
Reply
7 Replies
Highlighted
Nintex Newbie

Re: Query XML after Call Web Service

Is there a reason you aren't using the Query User Profile Action?  That way you can load the data into several collections and then loop through to find the data you need?

0 Kudos
Reply
Highlighted
Not applicable

Re: Query XML after Call Web Service

Unfortunately that come with the Enterprise Version of Nintex, which we don't have.

0 Kudos
Reply
Highlighted
Nintex Newbie

Re: Query XML after Call Web Service

If you have the Query XML action you can use the xpath builder and select the emergency contact field:

The Result is:

/xml/defaultNSSmiley TongueropertyData/defaultNS:emergencyContact

That returns just 'George Washington'

0 Kudos
Reply
Highlighted
Not applicable

Re: Query XML after Call Web Service

To supplement Patrick, i just want to say that to use the builder first of all copy XML data in input field and then press builder. Then builder creates tree from that xml and you wil be able to build your xpath query.

0 Kudos
Reply
Highlighted
Not applicable

Re: Query XML after Call Web Service

Unfortunatey the Builder function is not an option in Nintex 2007. However I used the example you provided and used an xpath of:

/xml/defaultNSSmiley TongueropertyData/defaultNS:EmergencyContactPerson

but I got an error message of Error=Namespace prefix 'defaultNS' is not defined.

My XML is

<xml><PropertyData xmlns="http://microsoft.com/webservices/SharePointPortalServer/UserProfileService"><IsPrivacyChanged>false<... xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">250-555-1111</Value></ValueData></Values></PropertyData><... xmlns="http://microsoft.com/webservices/SharePointPortalServer/UserProfileService"><IsPrivacyChanged>false<... xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">250-555-2222</Value></ValueData></Values></PropertyData><... xmlns="http://microsoft.com/webservices/SharePointPortalServer/UserProfileService"><IsPrivacyChanged>false<... xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">George Washinton</Value></ValueData></Values></PropertyData><PropertyData xmlns="http://microsoft.com/webservices/SharePointPortalServer/UserProfileService"><IsPrivacyChanged>false<... xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">250-555-3333</Value></ValueData></Values></PropertyData><... xmlns="http://microsoft.com/webservices/SharePointPortalServer/UserProfileService"><IsPrivacyChanged>false<... xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">250-555-4444</Value></ValueData></Values></PropertyData><...>

I am not sure what is causing the problem. Thanks for looking at this.

0 Kudos
Reply
Highlighted
Not applicable

Re: Query XML after Call Web Service

I remeber this problem, you need to to replace "xmlns" to xmlns:defaultNS or something very similar. Here is the post about that.

c# - Query an XmlDocument without getting a 'Namespace prefix is not defined' problem - Stack Overfl...

0 Kudos
Reply
Highlighted
Not applicable

Re: Query XML after Call Web Service

What I thought was going to be a fairly straightforward exercise isn't turning out that way. I had raised this as an issue with Nintex support a day before posting here but haven't heard back from them as yet. I have tried the recommendations from here, downloaded tools to try and create a correct Xpath structure but so far have not been successful.

I wonder if someone could use the attached file and use the Nintex builder to create the Xpath and post it back. If it works in your version of Nintex hopefully it would work in mine, or I could create a support issue.

Thanks in advance.

0 Kudos
Reply