Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

sgmlReader - why is my query finding no results

$
0
0
I'm trying to query an SGML file with sgmlReader, but the query is not finding any results. The code I have is:

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.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>