<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP:Header/> <SOAP:Body> <ns0:MT_COMMON xmlns:ns0="http://www.db.com"> <KEY>关键标示</KEY> <DATAJSON>数组内容</DATAJSON> </ns0:MT_COMMON> </SOAP:Body> </SOAP:Envelope>
针对上面格式的XML字符串,获取出来 数组内容或关键标示
解析代码:

try { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(strxml);//Load加载XML文件,LoadXML加载XML字符串 XmlElement root = xmlDoc.DocumentElement; XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDoc.NameTable); XmlNode xnode = root.FirstChild; nsmgr.AddNamespace("ns0", "http://www.db.com"); value = xnode.SelectSingleNode("//ns0:MT_COMMON", nsmgr) .SelectSingleNode("DATAJSON").InnerText; } catch (Exception ex) { throw new Exception(ex.Message); } return value;