I'm trying to query an SGML file with sgmlReader, but the query is not finding any results. The code I have is:
In the document i'm querying i clearly have the element and attribute <security class="3"> so i can't see why it's not finding it. I've debugged and it's looking in the right place for the file etc. Help appreciated. Thank you.
string[] projectFiles = Directory.GetFiles(path, typeExtention, SearchOption.AllDirectories); foreach (string file in projectFiles) { // setup SgmlReader var sgmlReader = new Sgml.SgmlReader(); var myStringreader = new StringReader(File.ReadAllText(file)); sgmlReader.DocType = "HTML"; sgmlReader.WhitespaceHandling = WhitespaceHandling.All; sgmlReader.CaseFolding = Sgml.CaseFolding.ToLower; sgmlReader.InputStream = myStringreader; XElement root = XElement.Load(sgmlReader); IEnumerable<XElement> selectedElement = from el in root.Elements("security") where (string)el.Attribute("class") == "3" select el; foreach (XElement el in selectedElement) MessageBox.Show("text" + el); }
In the document i'm querying i clearly have the element and attribute <security class="3"> so i can't see why it's not finding it. I've debugged and it's looking in the right place for the file etc. Help appreciated. Thank you.