I'm having a hard time parsing the nodes that have both attributes and descendants.
I need to get into customer node and parse everything below it to a value for use on a web page.
var contacts = from c in xdoc.Descendants("contact")
select new Contact
{
Email = (string)c.Element("email"),
HomePhone = (string)c.Element("phone").Attribute("type") // ?
};
And my XML:
<customer>
<contact>
<name part="first">Rick</name>
<name part="last">Smith</name>
<email>[email protected]</email>
<phone type="home">2299998989</phone>
<phone type="work">2298887878</phone>
<phone type="cell">2297778878</phone>
<address type="home">
<street line="1">4001 Coleman Rd</street>
<street line="2">Ste. 99</street>
<city>Tempe</city>
<regioncode>AZ</regioncode>
<postalcode>43444</postalcode>
</address>
</contact>
<comments>Customer comments</comments>
</customer>
<vendor>
<contact>
<name part="full" type="salesperson">Joe Smith</name>
</contact>
</vendor>