第一個問題,
1. 首先需要引入命名空間,
2. 其次,在用xpath查找結點時,在selectNodes等方法中再次帶入命名空間
如
XmlDocument doc = new XmlDocument(); doc.Load(currentXbrl); XmlNamespaceManager nsp = new XmlNamespaceManager(doc.NameTable); //導入命名空間 nsp.AddNamespace("neeq", "http://www.neeq.com.cn/neeq/cor/2017-12-31"); nsp.AddNamespace("so4217", "http://www.xbrl.org/2003/iso4217"); nsp.AddNamespace("xbrldi", "http://xbrl.org/2006/xbrldi"); nsp.AddNamespace("cas", "http://xbrl.mof.gov.cn/taxonomy/2015-03-31/cas"); nsp.AddNamespace("ifrs-full", "http://xbrl.ifrs.org/taxonomy/2014-03-05/ifrs-full"); string snode = "ifrs-full:ProfitLossAttributableToOwnersOfParent"; XmlElement root = doc.DocumentElement; var xnodes = root.SelectNodes(snode, nsp);//在查找結點時再次引用命名空間
第二個問題,用and連接多個屬性
var node=root.SelectSingleNode("OperatingRevenue[@contextRef='C_duration_20170101 - 20171231' and @unitRef='CNY'");
參考:
https://blog.csdn.net/jiangyu912/article/details/4676510
http://www.cnblogs.com/ifantastic/p/3670278.html