I am trying to parse the following input string for the my function below, but I keep getting the exception “Length of aA isnt matching length of bA”.
I have tried using regex to filter through but I am still struggling to get it parsed. Any suggestions would be very helpful. Thank you.
String a = Illiquidity option, credit model minted, Pricing service unveiled
string b = <P align=justify>RiskSpan has released a proprietary independent daily pricing service for structured products and mortgage assets. Real-time pricing and can process thousands of securities in virtually minutes, it says.</P><P align=justify>Joe Sturtevant, co-founder and pricing executive at RiskSpan, comments: "We are now pricing bonds in the manner in which a trader would and providing context that streamlines the audit process."</P>, <P align=justify>RiskSpan has released a proprietary independent daily pricing service for structured products and mortgage assets. Real-time pricing and can process thousands of securities in virtually minutes, it says.</P><P align=justify>Joe Sturtevant, co-founder and pricing executive at RiskSpan, comments: "We are now pricing bonds in the manner in which a trader would and providing context that streamlines the audit process."</P>
What I have tried:
string a = testtitle();
string b = testStory();
string c = "";
string results = "";
string[] aA = a.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
Regex rgxPTag = new Regex("(<p>.*?<\\/p>)", RegexOptions.Singleline);
string[] bA = rgxPTag.Matches(b).Cast<match>().Select(m => m.Groups[1].Value).ToArray();
if (aA.Length == bA.Length)
{
for (int i = 0; i < aA.Length; i++)
{
DateTime dt = DateTime.Today;
XDocument doc = new XDocument(
new XDeclaration("1.0", "gb2312", string.Empty),
new XElement("article",
new XElement("status", "Approved"),
new XElement("title", aA[i].ToString()),
new XElement("subtitle", aA[i].ToString()),
new XElement("synopsis", bA[i].ToString() + "..."),
new XElement("url", c),
new XElement("display_date", dt.ToShortDateString())
));
results = results + Environment.NewLine + doc.ToString();
}
return results;
}
return "Length of aA isnt matching length of bA";
}