Extract Value from a XML Attribute with xpath/c# -


i working on extracting data xml file xpath , c# in script task in ssis. want fill infomation sql table later.

my input xml-file looks this

<order> <header dateofexecution="2017-06-22 08:30:09" orderid="5000206348" status="o" messageid="1" type="req" serviceproviderid="sp010" externalid1="b0ddcfece1a345338f20902401fa1e71" /> <body>     <oli>         <olicontrol oliid="1" subscriptionid="990448" />         <migopt>             <migratedoptions>                 <option operation="chg" optiontype="flndetails" optionid="o2o0056">                     <attribute name="fixedlineoption" value="2" />                     <attribute name="portingdate" value="2017-07-03 06:00:00" />                     <attribute name="portingwindow" value="06:00:00" />                     <attribute name="fixedlinesource" value="d001" />                     <attribute name="fixedlinetype" value="analog" />                     <attribute name="fixedlinenumber" value="490" />                     <attribute name="lac" value="06736" />                 </option>             </migratedoptions>         </migopt>     </oli> </body> </order> 

i manage value of "type" header with

 string  type = doc.selectsinglenode("//header/@type").innertext; 

but somehow functions doesn't work when trying values every attribute

 string portingdate = doc.selectsinglenode("//attribute[name='portingdate']/@value").innertext; 

where mistake?

you're missing @ before name. change this:

doc.selectsinglenode("//attribute[@name='portingdate']/@value"); 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -