我需要一些幫助從XPathNodeIterator返回一個XmlDocument對象。從XPathNodeIterator返回一個XmlDocument
這是我要怎樣做:
public XmlDocument GetFilteredXML(XmlDocument baseXML, int codeID)
{
XPathNavigator nav = baseXML.CreateNavigator();
string xpath = /*some expression based on codeID*/;
XPathExpression exp = nav.Compile(xpath);
exp.AddSort(/*do some sorting*/);
XPathNodeIterator iter = exp.Select(exp);
// Here how do I return an XmlDocument object from
// the iterator which contains the selected nodes only?
}
我使用XPathExpression添加了一些排序條件。 – Daniel 2010-07-15 17:30:48
OuterXml屬性按原樣返回整個xml(未過濾) – Daniel 2010-07-15 17:40:08