Question : querying xml using node name

I get an xml in a webservice response and need to be able to filter through it by arrival date and period.
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
        XmlDocument doc = new XmlDocument();
        doc.Load(res.GetResponseStream());
        String xmlstr = doc.InnerXml;
<methodResponse>
- <params>
- <param>
- <value>
- <struct>
- <member>
  <name>period</name>
- <value>
  <string>1w</string>
  </value>
  <name>arrival-date</name>
- <value>
  <string>21-08-2010</string>
  </value>
  <name>arrival-time-from</name>
- <value>
  <string>1600</string>
  </value>
  <name>arrival-time-until</name>
- <value>
  <string>1800</string>
  </value>
  <name>departure-date</name>
- <value>
  <string>28-08-2010</string>
  </value>
  <name>departure-time</name>
- <value>
  <string>1000</string>
  </value>
  <name>request</name>
- <value>
  <string>No</string>
  </value>
  <name>price</name>
- <value>
  <string>579</string>
  </value>
  <name>price-excl-discount</name>
- <value>
  <string>579</string>
  </value>
    </member>
- <member>
  <name>period</name>
- <value>
  <string>2w</string>
  </value>
  <name>arrival-date</name>
- <value>
  <string>21-08-2010</string>
  </value>
  <name>arrival-time-from</name>
- <value>
  <string>1600</string>
  </value>
  <name>arrival-time-until</name>
- <value>
  <string>1800</string>
  </value>
  <name>departure-date</name>
- <value>
  <string>04-09-2010</string>
  </value>
  <name>departure-time</name>
- <value>
  <string>1000</string>
  </value>
  <name>request</name>
- <value>
  <string>No</string>
  </value>
  <name>price</name>
- <value>
  <string>1125</string>
  </value>
  <name>price-excl-discount</name>
- <value>
  <string>1125</string>
  </value>
  </member>
how can i filter it so i can say something like
if(period = "1w") and if(arrival-date = "21-08-2010") then show me all the nodes within the <member></member>

Answer : querying xml using node name

You are right; this xml format is different to use xpath names (with XmlDataSource). one thing you can do is get the individual values from the member nodes and set values in the labels/controls like shown below...see if this helps...
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
if (nodeArrivalDate != null
	&& nodeArrivalDate.NextSibling.InnerText == arrivalDate)
{

	Label_1.Text = GetFieldTextValue(memberNode, "price");
	Label_2.Text = GetFieldTextValue(memberNode, "price-excl-discount");

}

...

// GetFieldTextValue is method in the same class

private static string GetFieldTextValue(XmlNode memberNode, string fieldName)
        {
            string textValue = string.Empty;

            XmlNode nodeField = memberNode.SelectSingleNode(string.Format("name[.=\"{0}\"]", fieldName));
            if (nodeField != null && nodeField.NextSibling != null)
            {
                textValue = nodeField.NextSibling.InnerText;
            }

            return textValue;
        }
Random Solutions  
 
programming4us programming4us