XML namespace 太恶心,不知道是哪个家伙用来恶心人的。
StreamReader sr = new StreamReader(File.OpenRead(filepaths[filenumber]), Encoding.GetEncoding(XmlEncoding));
filenumber++;
StringBuilder sb = new StringBuilder();
string line;
// Read in xml dlfile
while ((line = sr.ReadLine()) != null)
{
line = line.Replace("xmlns=\"http://www.XMLnamespace太恶心.org"", "").Trim();
line = line.Replace("xmlns:h=\"http://www.w3.org/1999/xhtml\"", "").Trim();
line = line.Replace("xmlns:xi=\"http://www.w3.org/2001/XInclude\"", "").Trim();
line = line.Replace("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"", "").Trim();
line = line.Replace("xsi:", "").Trim();
sb.Append(line);
}
XPathDocument xPathDoc = new XPathDocument(new StringReader(sb.ToString()));
XPathNavigator xNav = xPathDoc.CreateNavigator();
直接代码