I have some projects in an XML file. eg. Multiple projects like the one below in the same file . I want to search all project entries where FluidTypes matches a particular string .
<?xml version="1.0" encoding="utf-8"?>
<data>
<Project ID="P-2014-000037">
<Name>FDP001_Bakken</Name>
<Manager>shell</Manager>
<Area>NAM</Area>
<Field>Bakken</Field>
<Type>Time and Material External</Type>
<Country>USA</Country>
<Value>3.5</Value>
<Geomarket>NAM</Geomarket>
<FormationTypes>Carbonate</FormationTypes>
<FormationTypes>Coal</FormationTypes>
<FormationTypes>Fractures</FormationTypes>
<FormationTypes>Sandstone</FormationTypes>
<FluidTypes>Gas Cond</FluidTypes>
<FluidTypes>Heavy Oil</FluidTypes>
<DriveMechanisms>Compaction</DriveMechanisms>
<DriveMechanisms>Aquifer</DriveMechanisms>
<EORProcesses>CO2</EORProcesses>
<EORProcesses>CSS</EORProcesses>
</Project>
</data>
I am using the follwing code to search for Geomarket matches :
IEnumerable<XElement> values1 = from el1 in root.Elements("Project").
Where(r => regEx1.IsMatch(r.Element("Geomarket").Value))
select el1;
when I use same for Fluid type (which has multiple elements ):
IEnumerable<XElement> values1 = from el1 in root.Elements("Project").
Where(r => regEx1.IsMatch(r.Element("FluidTypes").Value))
select el1;
It only checks for a match with the first element with name Fluid Types and not ALL fluid types elements . As a result only Gas Cond matches this project but Heavy Oil does not.
How to make a query across all Fluid types search ?
I want to search all project entries where FluidTypes matches a particular stringFor example?