Given this XML found here.
How can I get each contact item individually?
For exam开发者_StackOverflow社区ple, say I wanted to get only twitter:
I tried this:
return doc.XPathSelectElement("/ipb/profile/contactinformation/contact[type/text() = 'LinkedIn']/value").Value;
But that returns nothing. Any help?
/test/contactinfo/contact[type = 'Twitter']/address
If that doesn't work, try
/test/contactinfo/contact[type/text() = 'Twitter']/address
var profile = doc.Root.Element("profile");
var contactinfo = profile.Element("contactinformation");
var contacts = from contact in contactinfo.Elements("contact")
where (string)contact.Element("title") == "Twitter"
select contact;
var result = (string)contacts.Single().Element("value");
精彩评论