How to get an XML node using a SSIS XPATH XML task -


i trying use xml task in ssis session id value xml:

<?xml version="1.0" encoding="utf-16"?> <authenticationresult xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema">     <authenticated xmlns="[link]">true</authenticated>     <sessionid xmlns="[link]">0000-0000000-00000000000-000000</sessionid>     <loginid xmlns="[link]">000000</loginid>     <login_name xmlns="[link]">[username]</login_name>     <user_nbr xmlns="[link]">0000</user_nbr>     <partition_id xmlns="[link]">3</partition_id>     <is_parent_mail_user xmlns="[link]">0</is_parent_mail_user>     <parent_user_id xmlns="[link]" />     <user_id xmlns="[link]">[username]</user_id> </authenticationresult> 

however cant task return session id

task setup:

operation type: xpath sourcetype: file connection source: testfile.xml  saveoperationresult: true destinationtype: variable destination: user::sessionid overwritedestination: true  secondoperandtype: direct input secondoperand: //sessionid  namespaces: (collection) putresultsinonenode: false xpathoperation: values 

no name spaces specified.

i have googled around can't figure out why not working...

you can @ this answer suggestions xpath syntax. can make use of local-name() read element names without namespace. should able extract session id value with:

 <local name="sessionid"/>  <xmltask source="${xml.file}">     <copy path="/*[local-name()='authenticationresult']/*[local-name()='sessionid']/text()"           property="sessionid"/>  </xmltask>  <echo message="sessionid = ${sessionid}"/> 

alternatively, simplified syntax below might work:

 <xmltask source="${xml.file}">     <copy path="//:authenticationresult/:sessionid/text()"           property="sessionid"/>  </xmltask> 

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -