countrymeister
asked on
Query an xml file
I have an xml file, that consists of the following structure.
<XtraSerializer version="1.0" application="PivotGridCont rol">
<property name="#LayoutVersion" isnull="true" />
<property name="$PivotGridControl" iskey="true" value="PivotGridControl">
<property name="Fields" iskey="true" value="41">
<property name="Item1" isnull="true" iskey="true">
<property name="AreaIndex">0</proper ty>
<property name="Name">fieldCode</pro perty>
<property name="Area">RowArea</prope rty>
<property name="FilterValues" isnull="true" iskey="true">
<property name="DeferFilterString" />
<property name="ValuesCore" iskey="true" value="0" />
<property name="Values">~Xtra#Array0 , </property>
<property name="ShowBlanks">true</pr operty>
<property name="FilterType">Excluded </property >
</property>
</property>
<property name="Item2" isnull="true" iskey="true">
<property name="AreaIndex">1</proper ty>
<property name="Name">fieldGroup</pr operty>
<property name="Area">RowArea</prope rty>
<property name="FilterValues" isnull="true" iskey="true">
<property name="DeferFilterString" />
<property name="ValuesCore" iskey="true" value="0" />
<property name="Values">~Xtra#Array0 , </property>
<property name="ShowBlanks">true</pr operty>
<property name="FilterType">Excluded </property >
</property>
</property>
<property name="Item3" isnull="true" iskey="true">
<property name="AreaIndex">2</proper ty>
<property name="Name">fieldProduct</ property>
<property name="Area">ColumnArea</pr operty>
<property name="FilterValues" isnull="true" iskey="true">
<property name="DeferFilterString" />
<property name="ValuesCore" iskey="true" value="0" />
<property name="Values">~Xtra#Array0 , </property>
<property name="ShowBlanks">true</pr operty>
<property name="FilterType">Excluded </property >
</property>
</property>
</property>
</XtraSerializer>
I need to loop through all the Items under the element Fields and get the Name and Area attribtutes for each Item
Basically loop through this node
<property name="Fields" iskey="true" value="41">
<XtraSerializer version="1.0" application="PivotGridCont
<property name="#LayoutVersion" isnull="true" />
<property name="$PivotGridControl" iskey="true" value="PivotGridControl">
<property name="Fields" iskey="true" value="41">
<property name="Item1" isnull="true" iskey="true">
<property name="AreaIndex">0</proper
<property name="Name">fieldCode</pro
<property name="Area">RowArea</prope
<property name="FilterValues" isnull="true" iskey="true">
<property name="DeferFilterString" />
<property name="ValuesCore" iskey="true" value="0" />
<property name="Values">~Xtra#Array0
<property name="ShowBlanks">true</pr
<property name="FilterType">Excluded
</property>
</property>
<property name="Item2" isnull="true" iskey="true">
<property name="AreaIndex">1</proper
<property name="Name">fieldGroup</pr
<property name="Area">RowArea</prope
<property name="FilterValues" isnull="true" iskey="true">
<property name="DeferFilterString" />
<property name="ValuesCore" iskey="true" value="0" />
<property name="Values">~Xtra#Array0
<property name="ShowBlanks">true</pr
<property name="FilterType">Excluded
</property>
</property>
<property name="Item3" isnull="true" iskey="true">
<property name="AreaIndex">2</proper
<property name="Name">fieldProduct</
<property name="Area">ColumnArea</pr
<property name="FilterValues" isnull="true" iskey="true">
<property name="DeferFilterString" />
<property name="ValuesCore" iskey="true" value="0" />
<property name="Values">~Xtra#Array0
<property name="ShowBlanks">true</pr
<property name="FilterType">Excluded
</property>
</property>
</property>
</XtraSerializer>
I need to loop through all the Items under the element Fields and get the Name and Area attribtutes for each Item
Basically loop through this node
<property name="Fields" iskey="true" value="41">
ASKER
Hi ! FernandoSoto
I need all the Items that have aboth these attributes, because sone of my nodes could have only the name and no area attribute.
I need all the Items that have aboth these attributes, because sone of my nodes could have only the name and no area attribute.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The following is using Linq to XML to return the property nodes who's attributes are either name="Name" or name="Area"
Open in new window