Microsoft.Protocols.TestSuites.MS_ASAIRS.TestSuiteHelper.GetDataInnerText C# (CSharp) Method

GetDataInnerText() static private method

Get the inner text of specified element.
static private GetDataInnerText ( XmlElement lastRawResponse, string parentNodeName, string nodeName, string subject ) : string
lastRawResponse System.Xml.XmlElement The raw xml response.
parentNodeName string The parent element of the specified node.
nodeName string The name of the node.
subject string The subject of the specified item.
return string
        internal static string GetDataInnerText(XmlElement lastRawResponse, string parentNodeName, string nodeName, string subject)
        {
            string data = null;
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(lastRawResponse.OuterXml);
            XmlNodeList subjectElementNodes = doc.SelectNodes("//*[name()='Subject']");
            for (int i = 0; i < subjectElementNodes.Count; i++)
            {
                if (subjectElementNodes[i].InnerText == subject)
                {
                    XmlNodeList bodyElementNodes = doc.SelectNodes("//*[name()='" + parentNodeName + "']");
                    XmlNodeList dataElementNodes = bodyElementNodes[i].SelectNodes("*[name()='" + nodeName + "']");
                    data = dataElementNodes[0].InnerText;
                    break;
                }
            }

            return data;
        }