Extraction of Values from an XML SOAP Response in C#


i trying write down code read soap response message , extract values without success.

i trying extract scalar values starting @ node <structure>.

here code:

        //extracting xml http message.          xmldoc.loadxml(xmlhttp.responsetext);          xmlnamespacemanager nsmgr = new xmlnamespacemanager(xmldoc.nametable);          nsmgr.addnamespace("ns", "http://messages.ara.algorithmics.com");          nsmgr.addnamespace("ns2", "http://ws.ara.algorithmics.com");                      xmlelement root = xmldoc.documentelement;          xmlnode root1 = root.selectsinglenode("//structure", nsmgr); 

the message looking this:

  <?xml version='1.0' encoding='utf-8'?>             <s:envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">             <s:body>             <getstructurestatelessresponse xmlns="http://ws.ara.algorithmics.com" xmlns:ns2="http://messages.ara.algorithmics.com">             <contextid>interactive_cwmadmin20140828134101_base</contextid>             <userid>cwmadminsimulation_10267</userid>             <parameters>                 <aggregation>a:flat</aggregation>                 <currency>c:usd</currency>                 <depth>2</depth>                 <path requestedvalue="portfolio://all%20portfolios/group">portfolio://actual/group</path>             </parameters>             <outputdefs>                 <outputdef definitionid="od0">                     <outputid>o:price</outputid>                     <annualized>false</annualized>                     <currency>c:usd</currency>                     <nominalfx>false</nominalfx>                 </outputdef>                 <outputdef definitionid="od1">                 <outputid>o:value</outputid>                 <annualized>false</annualized>                 <currency>c:usd</currency>                 <nominalfx>false</nominalfx>                 </outputdef>                 <outputdef definitionid="od2">                 <outputid>o:unitdirtyprice</outputid>                 <annualized>false</annualized>                 <currency>c:usd</currency>                 <nominalfx>false</nominalfx>                 </outputdef>             </outputdefs>             <structure>                 <port childcount="316" expandednodename="position view" name="position view" nodeid="669">             <outputresults>                 <scalar ref="od0" value="1.890480805674964e7"/>                 <scalar ref="od1" value="1.890480805674964e7"/>             <ratio ref="od2" value="nan"/></outputresults>             <pos locked="true" name="cf_if asset@spl_ase@annuitant mortality improves" nodeid="347" secid="cf_if asset@spl_ase@annuitant mortality improves">             <outputresults>             <scalar ref="od0" value="0.0"/><scalar ref="od1" value="0.0"/>             <ratio ref="od2" value="0.0"/></outputresults>             </pos>             <pos locked="true" name="cf_if asset@spl_ase@assured lives mortality increases" nodeid="359" secid="cf_if asset@spl_ase@assured lives mortality increases">


hi ;

thank again help. manage find mistake. when calling node, wasn't doing correctly.

should have done this:xmlnode root1 = root.selectsinglenode("//ns2:structure", nsmgr);

this works fine , calls directly structure node.

regards.

brice



Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

BizTalk Server 2013 Azure VM Log Shipping and HA for hosts

How to Share webservice object to all user