How to check whether a expected element value length is present in the value of given XPath of XML
There is a sample code to check whether any expected element value length is present in XPath in xml file or not. User can set xpath , expected element value length and xml file dynamically to check this. Code has been developed in C# whereas application is windows based.
I have developed the method which will give you true as a result if expected element value length is present in the XPath of XML file. If that expected element value length is not present in xpath of xml file then it will give false as a result.
User has to give parameters as xpathvalue , xml file path , expected element value length in the method.
Create a class library in which put this code snippet and call whenever it is required.
public bool Match_element_value_length (string user_defined_xpath, string user_defined_xml_file, string user_defined_expected_length)
bool result_val = false;
XmlDocument user_defined_xml_doc = new XmlDocument();
XmlNodeList my_nodeList = user_defined_xml_doc.SelectNodes(user_defined_xpath);
foreach (XmlNode my_node in my_nodeList)
if (Convert.ToString(my_node.InnerText.Length) == user_defined_expected_length)
result_val = true;
result_val = false;