> I assume you meant to process both BORROWER elements (as they not attributes, but elements). Following is a modified
> version of your code
>
> XmlNodeList nodeList = xml.SelectNodes("REQUEST_GROUP/REQUEST/REQUEST_DATA/BORROWER");
>
> foreach (XmlNode node in nodeList)
> {
> String fn = node.Attributes["_FirstName"].Value;
> String ln = node.Attributes["_LastName"].Value;
> MessageBox.Show(fn);
> }
This would cause a problem if the required attribute was not present since Attributes["_FirstName"] would return null.
You can get around this problem by slightly modifying the XPath query to pull back only those nodes that have the
required attribute:
***
XmlNodeList nodeList =
xml.SelectNodes("REQUEST_GROUP/REQUEST/REQUEST_DATA/BORROWER[@_FirstName]");
***
Of course if the attribute is required in your schema then this makes no difference so either version will work in that
case.
Hope this helps,
Mike
- Microsoft Visual Basic MVP -
E-Mail:
(E-Mail Removed)
WWW:
Http://EDais.mvps.org/