473,378 Members | 1,451 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,378 software developers and data experts.

HtmlTextWriter or XmlTextWriter?

I need to export an HTML file, conforming to HTML 4.01 Strict in UTF-8.
I have written code for this in XmlTextWriter. Unfortunately, there seem
to be no way to remove the XML declaration. The WriteStartDocument()
method must be called before writing the root element.

So I had a look at HtmlTextWriter instead, but I can't find a way to
save a document from there, no way to add a DOCTYPE declaration, and no
way to set the encoding.

Can it be done in .NET?

Gustaf
Nov 16 '05 #1
2 5516
HtmlTextWriter is (somewhat) non-validating, I use it only to inject code
snippets into regions of a page. It renders html directly to the output
stream. You can use the Write and WriteLine methods to write any string you
want, but it needs to override a control's render method.

Any chance you can use XHTML 1.0 instead?
http://weblogs.asp.net/jezell/archiv.../24/33376.aspx

ok,
aq

"Gustaf Liljegren" <gu*****@algonet.se> wrote in message
news:eo**************@TK2MSFTNGP11.phx.gbl...
I need to export an HTML file, conforming to HTML 4.01 Strict in UTF-8.
I have written code for this in XmlTextWriter. Unfortunately, there seem
to be no way to remove the XML declaration. The WriteStartDocument()
method must be called before writing the root element.

So I had a look at HtmlTextWriter instead, but I can't find a way to
save a document from there, no way to add a DOCTYPE declaration, and no
way to set the encoding.

Can it be done in .NET?

Gustaf

Nov 16 '05 #2
Ahmed Qurashi wrote:
Any chance you can use XHTML 1.0 instead?
http://weblogs.asp.net/jezell/archiv.../24/33376.aspx


Thank you. I absolutely prefer XHTML, but in this case it's not a good
idea. First, the leading browser chokes on the XML declaration. Second,
the docs created will usually be delievered as "text/html" instead of
"application/xhtml+xml".

Seems the way out is old-fashioned string handling. :-)

Gustaf
Nov 16 '05 #3

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

Similar topics

5
by: Jain, Pranay Kumar | last post by:
Hello Everyone, I have written a simple app. that converts the dataset into excelspreadsheet. The App. uses the following architecture. First it generates the dataset with corresponding...
3
by: Magnus | last post by:
can anyone help me on how to create and manipulate a xmttextwriter without having to craete a physical file. I have an application that should return data in xml. But I do not want to create a...
4
by: H Lee | last post by:
Hi, I'm an XML newbie, and not sure if this is the appropriate newsgroup to post my question, so feel free to suggest other newgroups where I should post this message if this is the case. I'm...
1
by: Riko Eksteen | last post by:
Hi I'm reading an xml file into an XmlDocument, adding some nodes, and writing it back out. I would like the nodes I add to assume the same level of indeting as the rest of the document. (I load...
2
by: Steve | last post by:
I'm an XML newb. I'm serializing a class and when I inspect the xml file, all the data is on one line rather than being nested and indented Is that normal? <code> StreamWriter sw = new...
4
by: Einar Høst | last post by:
Hi, I'm having weird problems using StringWriter and XmlTextWriter. My code looks like this: StringWriter sw = new StringWriter(CultureInfo.InvariantInfo); XmlTextWriter xtw = new...
3
by: Lee Chapman | last post by:
Hi, I want my ASP.NET web application to use a custom HtmlTextWriter. i.e. I want the object that the Framework passes to System.Web.UI.Control.Render() to be my own object, MyHtmlTextWriter,...
4
by: quest | last post by:
Is there anyway I can generate the xml in the following format using XmlTextWriter ? Intended output: <?xml version="1.0" ?> I tried: XmlTextWriter xmlWriter = new...
3
by: GaryDean | last post by:
I'm using an XmlTextWriter and it's various methods such as WriteElementString, WriteStartElement, WriteEndElement, etc to create an xml document. When I instantiate the XmlTextWriter to a file......
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...

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.