473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

c# Rookie Help regarding :: Parsing XML Error

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
Nov 15 '05 #1
2 1434
//w.WriteLine("<!-- File: parse.cs -->");

should be

//w.WriteLine("<!-- File: parse.cs");

you close your comment three lines later.

"Daveg" <Da**@Guenthners.com> wrote in message
news:0a****************************@phx.gbl...
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
Nov 15 '05 #2
Well, I changed code and still getting error. Updated
code:

w.WriteLine("<!-- File: parse.cs");
w.WriteLine("File: parse.cs");
w.WriteLine("Time: " + str);
w.WriteLine("Auth: Dave Guenthner");
w.WriteLine("-->");
w.WriteLine("<?xml version=\"1.0\"?>");

Error is : System.XML.xmlException

Hmmmm....
Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Adonis | last post by:
When parsing my html files, I use handle_pi to capture some embedded python code, but I have noticed that in the embedded python code if it contains html, HTMLParser will parse it as well, and thus...
8
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
7
by: Steve D. Perkins | last post by:
Hello all - I'm a Java and C++ developer, looking to pick up some Python and wxPython skills for prototyping and quick projects. I've been developing for about 15 years, and am very familiar...
11
by: Don Bruder | last post by:
Got a stumper here. I imagine that for someone experienced in C++, this is too pathetic for words. For a rookie, using this project as a sort of "midterm exam" in his self-taught "how to program in...
2
by: Cigdem | last post by:
Hello, I am trying to parse the XML files that the user selects(XML files are on anoher OS400 system called "wkdis3"). But i am permenantly getting that error: Directory0: \\wkdis3\ROOT\home...
16
by: Terry | last post by:
Hi, This is a newbie's question. I want to preload 4 images and only when all 4 images has been loaded into browser's cache, I want to start a slideshow() function. If images are not completed...
3
by: David Svoboda | last post by:
I have a server program that takes commands and acts on them. The server program can also take these commands from an input file or standard input (mainly for testing purposes). As such, I often...
14
by: GabrielESandoval | last post by:
I need to make a registration page for a community service volleyball tournament our organization is doing. I am VERY NEW to ASP. Would the easiest way to make it be just doing it on frontpage...
4
by: amit3281 | last post by:
Hi, I am getting error Exception in thread "main" java.lang.OutOfMemoryError: Java heap space when i am using xercus 2.9.0 JDK1.5, The XML file size is approx 1G when i get document.parse...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.