我有这个xml:
XNamespace g = "http://something.com";
XElement contacts =
new XElement("Contacts", new XAttribute(XNamespace.Xmlns + "g", g),
new XElement("Contact",
new XElement(g + "Name", "Patrick Hines"),
new XElement("Phone", "206-555-0144"),
new XElement("Address",
new XElement("street", "this street"))
)
);
我想选择 gName 元素,所以我尝试了但不起作用:
var node = doc.SelectSingleNode("/Contacts/g:Name[text()=Patrick Hines');