xml - Issue with XmlNode.SelectNodes -


i'm getting web service below xml , i'm try select ttcontext nodes need parse contextvalue node contextgroup = pcsessionid.

i figured first make sure @ ttcontext nodes , work there modify code go when run below code node list contains 0 nodes. can lead me in right direction?

dim xmldoc xmldocument = new xmldocument

xmldoc.loadxml(e.innerxml)

e.innerxml contains below xml:

   <soap-env:envelope          xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"          xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"          xmlns:xsd="http://www.w3.org/2001/xmlschema">         <soap-env:body>            <apsrvresponse xmlns="urn:etimews:etimews">               <result xsi:nil="true" />               <dscontext>                  <ttcontext>                     <contextgroup>param</contextgroup>                     <contextname>pcpassword</contextname>                     <contextvalue>admin</contextvalue>                     <contextoperator />                     <contexttype />                  </ttcontext>                  <ttcontext>                     <contextgroup>param</contextgroup>                     <contextname>pcsessionid</contextname>                     <contextvalue>admin.8c4a11bf-a8e0-3e9e-df11-84e3cd76215d.bjzfvubladuixkmj</contextvalue>                     <contextoperator />                     <contexttype />                  </ttcontext>                  <ttcontext>                     <contextgroup>param</contextgroup>                     <contextname>pcuserid</contextname>                     <contextvalue>admin</contextvalue>                     <contextoperator />                     <contexttype />                  </ttcontext>               </dscontext>            </apsrvresponse>         </soap-env:body>      </soap-env:envelope> 

dim root xmlnode = xmldoc.documentelement dim nodelist xmlnodelist = root.selectnodes("/dscontext/ttcontext")

a little complicated namespaces. used xml linq

imports system.xml  imports system.xml.linq  module module1        sub main()          dim input string = _         "<soap-env:envelope" & _           " xmlns:soap-env=""http://schemas.xmlsoap.org/soap/envelope/""" & _           " xmlns:xsi=""http://www.w3.org/2001/xmlschema-instance""" & _           " xmlns:xsd=""http://www.w3.org/2001/xmlschema"">" & _          "<soap-env:body>" & _             "<apsrvresponse xmlns=""urn:etimews:etimews"">" & _                "<result xsi:nil=""true"" />" & _                "<dscontext>" & _                   "<ttcontext>" & _                      "<contextgroup>param</contextgroup>" & _                      "<contextname>pcpassword</contextname>" & _                      "<contextvalue>admin</contextvalue>" & _                      "<contextoperator />" & _                      "<contexttype />" & _                   "</ttcontext>" & _                   "<ttcontext>" & _                      "<contextgroup>param</contextgroup>" & _                      "<contextname>pcsessionid</contextname>" & _                      "<contextvalue>admin.8c4a11bf-a8e0-3e9e-df11-84e3cd76215d.bjzfvubladuixkmj</contextvalue>" & _                      "<contextoperator />" & _                      "<contexttype />" & _                   "</ttcontext>" & _                   "<ttcontext>" & _                      "<contextgroup>param</contextgroup>" & _                      "<contextname>pcuserid</contextname>" & _                      "<contextvalue>admin</contextvalue>" & _                      "<contextoperator />" & _                      "<contexttype />" & _                   "</ttcontext>" & _                "</dscontext>" & _             "</apsrvresponse>" & _          "</soap-env:body>" & _       "</soap-env:envelope>"            dim envelope xelement = xelement.parse(input)          dim ns xnamespace = envelope.name.namespace            dim contextgroup string = "pcsessionid"                    dim results = envelope.descendants().where(function(w) w.name.localname = "ttcontext" , _                         w.elements(w.name.namespace + "contextname").where(function(x) x.value = contextgroup).any()) _                         .select(function(y) new { _                                    .contextgroup = y.element(y.name.namespace + "contextgroup").value, _                                    .contextname = y.element(y.name.namespace + "contextname").value, _                                    .contextvalue = y.element(y.name.namespace + "contextvalue").value, _                                    .contextoperator = y.element(y.name.namespace + "contextoperator").value, _                                    .contexttype = y.element(y.name.namespace + "contexttype").value _                                     }).tolist()        end sub    end module  ​


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -