U can use,

XmlNodeList nodes = xDoc.SelectNodes("/Users/User/Lastname2");
if nodes.count>0 // if count >0 then there is a node else not



On Mon, Aug 23, 2010 at 3:31 PM, Greg Hile <[email protected]> wrote:

>  I am iterating through some xml nodes like so.
>
>
>
> XmlDocument xDoc = new XmlDocument();
>
> MyWebService.ClientService WS = new MyWebService.ClientService();
>
> XmlNode MyData = WS.GetUserInfo();
>
> xDoc.LoadXml(MyData.OuterXml);
>
> XmlNodeList nodes = xDoc.SelectNodes("/Users/User");
>
>
>
> foreach (XmlNode node in nodes)
>
> {
>
>    switch (node.Attributes["FieldTitle"].Value.Trim())
>
>    {
>
>       case ("Last Name"):
>
>       string nameLast = node.Attributes["LastName"].Value;
>
>    }
>
> }
>
>
>
> The thing is I would like to check to see if there is a “Last Name 2”
> attribute in the XML before iterating.
>
>
>
> Is there a way to just check for a “FieldTitle” named “Last Name 2” and
> then choose what path my code should take based up it’s value?
>
>
>
> Thanks,
>
> Greg
>
>
>
>
>
>
>
>
>

Reply via email to