public void inspectVulneravilityTable(HtmlNode table) { string headerSeparator; int cveIni; HtmlNodeCollection cols; HtmlNode head = table.SelectSingleNode("thead"); HtmlNodeCollection bodies = table.SelectNodes("tbody"); HtmlNode headRow = head.SelectSingleNode("tr"); HtmlNodeCollection headCols = headRow.SelectNodes("th"); HtmlNodeCollection headerSeparatorH; //HtmlNode bodyRows = body.SelectSingleNode("tr"); for (int c = 1; c < headCols.Count - 1; c++) //This for traverses the number of columns that have cve { headerSeparator = ""; cveIni = row; //for (int i = 2; i < bodyRows.Count; i++) //The first row has the header of the table and the second has the the column definition foreach (HtmlNode body in bodies) { foreach (HtmlNode HTMLRow in body.SelectNodes("tr")) //The first row has the header of the table and the second has the the column definition { if ((cols = HTMLRow.SelectNodes("td")) != null) //It means that this column is a header separator { if (isAffected(cols[c].InnerText)) // This means that wheter the corresponding coulumn contains MODERATE, CRITICAL LOW IMPORTANT { findRowsToCopyFrom(headerSeparator, cols[0].InnerText); } } else { if ((headerSeparatorH = HTMLRow.SelectNodes("th")) != null) { headerSeparator = (headerSeparatorH[0].InnerText).Trim(); } } } } getCVEandDescription(headCols[c].InnerText, cveIni); } }
public void Parse(string strHTML) { m_rows.Clear(); HTMLUtil util = new HTMLUtil(); string strTag = ""; int iPosStart = util.FindTag(strHTML, "<table", ref strTag, 0); if (iPosStart >= 0) { iPosStart += (int)strTag.Length; int iPosEnd = util.FindClosingTag(strHTML, "table", ref strTag, iPosStart) - 1; if (iPosEnd < 0) { iPosEnd = (int)strHTML.Length; } string strTable = strHTML.Substring(iPosStart, 1 + iPosEnd - iPosStart); int iTableRowStart = 0; do { iTableRowStart = util.FindTag(strTable, "<tr", ref strTag, iTableRowStart); if (iTableRowStart >= 0) { iTableRowStart += (int)strTag.Length; int iTableRowEnd = util.FindClosingTag(strTable, "tr", ref strTag, iTableRowStart) - 1; if (iTableRowEnd < 0) { break; } string strRow = strTable.Substring(iTableRowStart, 1 + iTableRowEnd - iTableRowStart); HTMLRow row = new HTMLRow(); row.Parse(strRow); m_rows.Add(row); iTableRowStart = iTableRowEnd + 1; } } while (iTableRowStart >= 0); } }
public void Parse(string strHTML) { m_rows.Clear(); HTMLUtil util = new HTMLUtil(); string strTag = ""; int iPosStart = util.FindTag(strHTML, "<table", ref strTag, 0); if (iPosStart >= 0) { iPosStart += (int)strTag.Length; int iPosEnd = util.FindClosingTag(strHTML, "table", ref strTag, iPosStart) - 1; if (iPosEnd < 0) { iPosEnd = (int)strHTML.Length; } string strTable = strHTML.Substring(iPosStart, 1 + iPosEnd - iPosStart); int iTableRowStart = 0; do { iTableRowStart = util.FindTag(strTable, "<tr", ref strTag, iTableRowStart); if (iTableRowStart >= 0) { iTableRowStart += (int)strTag.Length; int iTableRowEnd = util.FindClosingTag(strTable, "tr", ref strTag, iTableRowStart) - 1; if (iTableRowEnd < 0) break; string strRow = strTable.Substring(iTableRowStart, 1 + iTableRowEnd - iTableRowStart); HTMLRow row = new HTMLRow(); row.Parse(strRow); m_rows.Add(row); iTableRowStart = iTableRowEnd + 1; } } while (iTableRowStart >= 0); } }