Click here to Skip to main content
15,917,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HTML
<server><requests><Session.loginRq userName="admin" password="admin" />
<IntegrationCBO.ProcessWCFServiceRq name="test" binding="http" url="http://abrxmlsearch.asmx" searchString="53004085616" includeHistoricalDetails="N" authenticationGuid="88bf33e2-96a6-402c-a870-47c03af2a80b"></IntegrationCBO.ProcessWCFServiceRq><Session.closeRq /></requests></server>


How to fetch the searchstring value?

What I have tried:

C#
var Number = rootelement.Element("server").Element("requests").Element("Session.loginRq").Element("IntegrationCBO.ProcessWCFServiceRq").Attribute("searchString");
Posted
Updated 17-Oct-19 1:03am
v2
Comments
Richard MacCutchan 17-Oct-19 6:55am    
What happened when you ran that code?

1 solution

OK, let's start by formatting your XML into a readable table:
HTML
<server>
  <requests>
    <Session.loginRq userName="admin" password="admin" />
    <IntegrationCBO.ProcessWCFServiceRq 
      name="test" 
      binding="http" 
      url="http://abrxmlsearch.asmx" 
      searchString="53004085616" 
      includeHistoricalDetails="N" 
      authenticationGuid="88bf33e2-96a6-402c-a87047c03af2a80b">
    </IntegrationCBO.ProcessWCFServiceRq>
    <Session.closeRq />
  </requests>
</server>

Now you can clearly see that IntegrationCBO.ProcessWCFServiceRq is a child of the requests node, not Session.loginRq.
 
Share this answer
 
Comments
chandra sekhar 17-Oct-19 7:17am    
So what would be the solution?
Richard MacCutchan 17-Oct-19 7:45am    
It is fairly obvious. Use the correct nodes in the correct order to address the attribute you are interested in.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900