First I wanna say your xml string is not in a standard format and you need to write your customize parser ,,
As I see your xml string the code that can parse your string can be like below:
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(resulStr); // Load the XML document from the specified file
XmlNodeList response = xmlDoc.GetElementsByTagName("test1");
foreach (XmlNode xn in response)
{
XmlNodeList records = xn.SelectNodes("test2");
foreach (XmlNode record in records)
{
if (record != null)
{
for (int i = 0; i < record.ChildNodes.Count; i++)
{
var objfield = record.ChildNodes.Item(i).OuterXml;
var attributes = Utility.GetSrcInHTMLImgString(objfield);
var attrkey = attributes[1];
var attrvalue = attributes[0];
}
}
}
}
and also the GetSrcInHTMLImgString functon use for parse each test3 field(I use html parser for each test3 field) ,,, below code is the htl parser according to your xml string:
public static List<string> GetSrcInHTMLImgString(string htmlString)
{
List<string> srcs = new List<string>();
string pattern1 = @"(?<=value="").*?(?="")";
string pattern2 = @"(?<=name="").*?(?="")";
Regex rgx1 = new Regex(pattern1, RegexOptions.IgnoreCase);
Regex rgx2 = new Regex(pattern2, RegexOptions.IgnoreCase);
MatchCollection matches1 = rgx1.Matches(htmlString);
MatchCollection matches2 = rgx2.Matches(htmlString);
string value1 = matches1[0].Value;
string value2 = matches2[0].Value;
srcs.Add(value1);
srcs.Add(value2);
return srcs;
}
I think if you use these code your problem solved,,
best regard