Click here to Skip to main content
15,909,530 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can any one please say...

How to make compier to skip the execution of commented code in an xml file..

even code in <!-- code --> this tags ,compiler is reading the code, how to skip the execution of commented code in xml file


please do reply,.
Posted
Comments
m19anand 24-Aug-11 4:05am    
no ma'm ,. even i tried <!-- code --> this tags, compiler compiling that code too,... how to skip

It depends on what are you using for parsing XML. You can use System.Xml.XmlTextReader; in this case, you can use its property Settings or the class System.Xml.XmlReaderSettings — it has a property IgnoreComments which will solve the problem; there are other very useful properties of the parsing.

See:
http://msdn.microsoft.com/en-us/library/system.xml.xmltextreader.aspx[^],
http://msdn.microsoft.com/en-us/library/system.xml.xmlreadersettings.aspx[^].

—SA
 
Share this answer
 
Comments
Tech Code Freak 24-Aug-11 5:30am    
My 5!
Sergey Alexandrovich Kryukov 24-Aug-11 10:13am    
Thank you, Code Freak.
--SA
m19anand 24-Aug-11 5:52am    
but how to set settings when parsing was done in such way..
please reply..
private void AddNode(XmlNode inXmlNode, TreeNode inTreeNode)
{
XmlNode xNode;
TreeNode tNode;
XmlNodeList nodeList;

// Loop through the XML nodes until the leaf is reached.
// Add the nodes to the TreeView during the looping process.
if (inXmlNode.HasChildNodes)
{
nodeList = inXmlNode.ChildNodes;
for (int i = 0; i <= nodeList.Count - 1; i++)
{
xNode = inXmlNode.ChildNodes[i];
inTreeNode.Nodes.Add(CreateTreeNode(xNode));
tNode = inTreeNode.Nodes[i];
AddNode(xNode, tNode);
}
}
else
{
// no children, so this is a leaf node
if (inXmlNode.Attributes.Count > 0)
{
inTreeNode.Text = inXmlNode.Attributes["title"] == null ? "Title" : inXmlNode.Attributes["title"].Value;
inTreeNode.ToolTipText = inXmlNode.Attributes["url"] == null ? "url" : inXmlNode.Attributes["url"].Value;
}
}
}
Sergey Alexandrovich Kryukov 24-Aug-11 10:15am    
Assign the property Settings to appropriate instance of System.Xml.XmlReaderSettings before you start parsing, say, when you construct the reader.
--SA
m19anand 24-Aug-11 10:38am    
ya ok i did it,...thanku verymuch,... thnks for support
skip code using

for ex..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900