XhtmlTextWriter Issue: cant write to page

T

TheReckter

I am fairly new to ASP and wanted to output certain parts of an xml
file directly to the page, I tried the following method however it did
not work, any help in correcting this issue would be greatly
appreciated

AppSettings As = new AppSettings();
XmlTextReader reader = new XmlTextReader(As.Loca + "./pages/" +
PageID.ToString() + "/page.xml");
XhtmlTextWriter writer = new XhtmlTextWriter(TextWriter.Null);
while (reader.Read())
{
if (reader.Name == "Name")
{
string x = reader.ReadString();
writer.WriteLine(reader.ReadString());
}
}
writer.Close();

this in my mind would print the page's name to the page, however it
does not work correctly, when debugging at
writer.WriteLine(reader.ReadString()); I can tell all variavles hold
the correct values therefore that is not an issue. Thankyou for your
help.
 
T

Teemu Keiski

Wouldn't the lines

string x = reader.ReadString();
writer.WriteLine(reader.ReadString());

be

string x = reader.ReadString();
writer.WriteLine(x);

as otherwise it kind of reads "over" the name.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,208
Latest member
RandallLay

Latest Threads

Top