D
Daveg
Hello, Rookie here. I am new at c# and put together a
script which is working fine grabbing some elements from
an XML file that I created. The problem is that I would
like to put at the top of the xml file some comments which
document time, date, etc. If I open the file with the
comments in a web browser it displays fine, but if I use
the GetElementsByTagName ("Some Element"); I get an error
as if the method does not ignore the comments, it tries to
parse them as well. Am I missing something?? For now I
have removed any comments but would like to have them
included.
Problem Code commented out:
//w.WriteLine("<!-- File: parse.cs -->");
//w.WriteLine("File: parse.cs");
//w.WriteLine("Time: " + str);
//w.WriteLine("-->");
XmlNodeList nodes = doc.GetElementsByTagName ("Patch");
foreach (XmlNode node in nodes)
{
string patchnames = node
["Name"].InnerText;
string subvalue = node
["Key"].InnerText;
//Console.WriteLine
("Subvalue " + subvalue + computername);
string keyvalue = node
["Value"].InnerText;
//Console.WriteLine
("keyvalue " + keyvalue + computername);
string priority = node
["Priority"].InnerText;
//Console.WriteLine
("keyvalue " + keyvalue + computername);
}
end of code snipet
Thanks in advance
script which is working fine grabbing some elements from
an XML file that I created. The problem is that I would
like to put at the top of the xml file some comments which
document time, date, etc. If I open the file with the
comments in a web browser it displays fine, but if I use
the GetElementsByTagName ("Some Element"); I get an error
as if the method does not ignore the comments, it tries to
parse them as well. Am I missing something?? For now I
have removed any comments but would like to have them
included.
Problem Code commented out:
//w.WriteLine("<!-- File: parse.cs -->");
//w.WriteLine("File: parse.cs");
//w.WriteLine("Time: " + str);
//w.WriteLine("-->");
XmlNodeList nodes = doc.GetElementsByTagName ("Patch");
foreach (XmlNode node in nodes)
{
string patchnames = node
["Name"].InnerText;
string subvalue = node
["Key"].InnerText;
//Console.WriteLine
("Subvalue " + subvalue + computername);
string keyvalue = node
["Value"].InnerText;
//Console.WriteLine
("keyvalue " + keyvalue + computername);
string priority = node
["Priority"].InnerText;
//Console.WriteLine
("keyvalue " + keyvalue + computername);
}
end of code snipet
Thanks in advance