How to select a <client> element where <domain> contains any specified value :
<config>
<client>
<name>Localhost</name>
<domains>
<domain>localhost</domain>
<domain>192.168.43.12</domain>
</domains>
<moduletype>t</moduletype>
<contactname>Home Manager</contactname>
<contactemail>[email protected]</contactemail>
<contactphone1>+133255111</contactphone1>
<contactphone2>+1332552</contactphone2>
</client>
<client>
<name>Client A</name>
<domains>
<domain>a.com</domain>
<domain>c.com</domain>
<domain>d.com</domain>
</domains>
<moduletype>t</moduletype>
<contactname>Client A</contactname>
<contactemail>[email protected]</contactemail>
<contactphone1>+12553254</contactphone1>
<contactphone2>+14403253</contactphone2>
</client>
</config>
For eg : if "192.168.43.12" domain is passed, it should select client Localhost, if "c.com" domain is passed, it should select client Client A
I have tried :
string domain_name = "192.168.43.12";
XElement record = xmldoc.Element("config").Elements("client").Elements("domains").Where(x => (string)x.Element("domain") == domain_name).SingleOrDefault();
But it produces null result;