1.读取带namespace的xml
public static string ReadXml(string path, string nodeName) { var xmlString = string.Empty; try { var xml = new XmlDocument(); xml.Load(path); XmlElement root = xml.DocumentElement; string nameSpace = root.NamespaceURI; XmlNamespaceManager nsmgr = new XmlNamespaceManager(xml.NameTable); nsmgr.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"); nsmgr.AddNamespace("nsCommon", "http://www.joia.or.jp/standardized/namespaces/Common"); nsmgr.AddNamespace("nsREF", "http://www.joia.or.jp/standardized/namespaces/REF"); nsmgr.AddNamespace("schemaLocation", "http://www.joia.or.jp/standardized/namespaces/Common Common_schema.xsd http://www.joia.or.jp/standardized/namespaces/REF REF_schema.xsd"); if (root == null) return xmlString; var node = root.SelectSingleNode(nodeName, nsmgr); if (node != null) { xmlString = node.InnerText; } } catch (Exception er) { throw new Exception(er.ToString()); } //Console.WriteLine(xmlString); return xmlString; }