Problem recognizing charcter entities
-
Hi, I have a problem with with parsing an XML document. In the document I have some character entities like I use XmlDocument.SelectNodes() method to select a specific set of nodes from the XML document, but it happens that some of the tags that are found to have these character entities inside them, and I would like to skip them. My question is that how can that be accomplished. I've tried to use regular expressions to filter out these kind of texts but it didn't work, it read only some empty strings. Any help is well appreciated!
-
Hi, I have a problem with with parsing an XML document. In the document I have some character entities like I use XmlDocument.SelectNodes() method to select a specific set of nodes from the XML document, but it happens that some of the tags that are found to have these character entities inside them, and I would like to skip them. My question is that how can that be accomplished. I've tried to use regular expressions to filter out these kind of texts but it didn't work, it read only some empty strings. Any help is well appreciated!
You can use internal general entities: XML: ]> Red Green Black C#: using System; using System.Xml; namespace Entity { class Program { static void Main(string[] args) { XmlDocument xml_doc = new XmlDocument(); xml_doc.Load("WithEntities.xml"); XmlNodeList colors = xml_doc.SelectNodes("/colors/color/@style"); foreach (XmlNode color_style in colors) { Console.WriteLine(color_style.Value); } } } } "We make a living by what we get, we make a life by what we give." --Winston Churchill
-
You can use internal general entities: XML: ]> Red Green Black C#: using System; using System.Xml; namespace Entity { class Program { static void Main(string[] args) { XmlDocument xml_doc = new XmlDocument(); xml_doc.Load("WithEntities.xml"); XmlNodeList colors = xml_doc.SelectNodes("/colors/color/@style"); foreach (XmlNode color_style in colors) { Console.WriteLine(color_style.Value); } } } } "We make a living by what we get, we make a life by what we give." --Winston Churchill
Thank you for your reply, but I think that if I do as you mentioned it won't work the way I need to be done. The scenario is as follows. The problem is that I wrote an example for the entitites that I look for but it actually dissapeared from the post message (probably because the reference is invisible). So I have an XML doc and I search for tags in it, but some of these tags contain character entities like & #160; (actually this is single word but I separated with a space just to be visible), and I don't want process such tags that contain this kind of information, I want to skip them. The problem is that when I select the specific nodes and I look for text entries inside them I can't recognize if an entry is a character entity just because it is substituted by the actual value of it (in the previous example I think that entity represents an empty line or whatever). I think now it is clear what I want to achive. Thanks in advance!