Hello,
Using code below to create an xml file, how do I specifiy utf-8 encoding in
the root element, ie create "<?xml version="1.0" encoding="utf-8"?>
Thanks!
-------------------------------------------
Dim xmlWriter As New
XmlTextWriter("C:\inetpub\wwwroot\rss2\20061019\te st.xml", Nothing)
xmlWriter.Formatting = Formatting.Indented
With xmlWriter
.WriteStartDocument()
.WriteStartElement("rss")
.WriteAttributeString("version", "2.0")
.WriteStartElement("channel")
.WriteElementString("title", "caseNumber" & ": " & "caseName")
.WriteElementString("link", "link")
.WriteElementString("description", "caseName")
.WriteElementString("lastBuildDate", Now.ToString("ddd, dd MMM
yyyy hh:mm:ss") & " GMT") '<<<<<<<<<<<<<<<<<<<<<<<<<<<
'.WriteElementString("pubDate", caseAdded.ToString("ddd, dd MMM
yyyy hh:mm:ss") & " GMT") 'Now())
.WriteStartElement("item")
.WriteElementString("title", "description")
.WriteStartElement("guid")
.WriteAttributeString("isPermaLink", Nothing, "false")
.WriteString(Guid.NewGuid.ToString)
.WriteEndElement()
' .WriteElementString("title", description)
.WriteElementString("description", "caseNumber")
.WriteElementString("link", "link")
'.WriteElementString("pubDate", dateModified & " 12:00:00 GMT")
'Now().ToString) <---------------------------change
.WriteElementString("pubDate", Now().ToString("ddd, dd MMM yyyy
hh:mm:ss") & " GMT")
.WriteEndElement() '<<<<<<<<<<<<<<<<<<<<<
.WriteEndElement()
.WriteEndElement()
.WriteEndDocument()
.Flush()
.Close()
End With
xmlWriter = Nothing 7 3479
Hi John,
I don't think <?xml version="1.0" encoding="utf-8"?is actually
supposed to be part of your XML document. Doesn't this XML directive
automatically get created by whatever mechanism you are using to
transmit the XML?
Usually, this is set by the content-type property (MIME type) of
whatever is actually performing the transmission.
Andy
Also, using the code below, I can't open the resulting xml file in IE7.0 and
it won't validate at www.feedvalidator.org unless I open it first in notepad
and then save it back. I make no changes to the file, I simply open and then
close it using notepad and then it validates in both. The file (before
opening/saving in notepad) will work in various rss readers, however, without
any error. Any ideas? Thanks!
"John Hopper" wrote:
Hello,
Using code below to create an xml file, how do I specifiy utf-8 encoding in
the root element, ie create "<?xml version="1.0" encoding="utf-8"?>
Thanks!
-------------------------------------------
Dim xmlWriter As New
XmlTextWriter("C:\inetpub\wwwroot\rss2\20061019\te st.xml", Nothing)
xmlWriter.Formatting = Formatting.Indented
With xmlWriter
.WriteStartDocument()
.WriteStartElement("rss")
.WriteAttributeString("version", "2.0")
.WriteStartElement("channel")
.WriteElementString("title", "caseNumber" & ": " & "caseName")
.WriteElementString("link", "link")
.WriteElementString("description", "caseName")
.WriteElementString("lastBuildDate", Now.ToString("ddd, dd MMM
yyyy hh:mm:ss") & " GMT") '<<<<<<<<<<<<<<<<<<<<<<<<<<<
'.WriteElementString("pubDate", caseAdded.ToString("ddd, dd MMM
yyyy hh:mm:ss") & " GMT") 'Now())
.WriteStartElement("item")
.WriteElementString("title", "description")
.WriteStartElement("guid")
.WriteAttributeString("isPermaLink", Nothing, "false")
.WriteString(Guid.NewGuid.ToString)
.WriteEndElement()
' .WriteElementString("title", description)
.WriteElementString("description", "caseNumber")
.WriteElementString("link", "link")
'.WriteElementString("pubDate", dateModified & " 12:00:00 GMT")
'Now().ToString) <---------------------------change
.WriteElementString("pubDate", Now().ToString("ddd, dd MMM yyyy
hh:mm:ss") & " GMT")
.WriteEndElement() '<<<<<<<<<<<<<<<<<<<<<
.WriteEndElement()
.WriteEndElement()
.WriteEndDocument()
.Flush()
.Close()
End With
xmlWriter = Nothing
I see now that this can be declared as a parameter of the constructor.
"John Hopper" wrote:
Hello,
Using code below to create an xml file, how do I specifiy utf-8 encoding in
the root element, ie create "<?xml version="1.0" encoding="utf-8"?>
Thanks!
-------------------------------------------
Dim xmlWriter As New
XmlTextWriter("C:\inetpub\wwwroot\rss2\20061019\te st.xml", Nothing)
xmlWriter.Formatting = Formatting.Indented
With xmlWriter
.WriteStartDocument()
.WriteStartElement("rss")
.WriteAttributeString("version", "2.0")
.WriteStartElement("channel")
.WriteElementString("title", "caseNumber" & ": " & "caseName")
.WriteElementString("link", "link")
.WriteElementString("description", "caseName")
.WriteElementString("lastBuildDate", Now.ToString("ddd, dd MMM
yyyy hh:mm:ss") & " GMT") '<<<<<<<<<<<<<<<<<<<<<<<<<<<
'.WriteElementString("pubDate", caseAdded.ToString("ddd, dd MMM
yyyy hh:mm:ss") & " GMT") 'Now())
.WriteStartElement("item")
.WriteElementString("title", "description")
.WriteStartElement("guid")
.WriteAttributeString("isPermaLink", Nothing, "false")
.WriteString(Guid.NewGuid.ToString)
.WriteEndElement()
' .WriteElementString("title", description)
.WriteElementString("description", "caseNumber")
.WriteElementString("link", "link")
'.WriteElementString("pubDate", dateModified & " 12:00:00 GMT")
'Now().ToString) <---------------------------change
.WriteElementString("pubDate", Now().ToString("ddd, dd MMM yyyy
hh:mm:ss") & " GMT")
.WriteEndElement() '<<<<<<<<<<<<<<<<<<<<<
.WriteEndElement()
.WriteEndElement()
.WriteEndDocument()
.Flush()
.Close()
End With
xmlWriter = Nothing
Well, I know that MS Notepad processes carriage returns and line feeds
differently than MS WordPad. I've seen this in UNIX generated files
that are opened in Notepad - all the line breaks are lost and instead
display as unprintable characters. But, when you open the same file in
MS WordPad, the line breaks are processed correctly.
I suspect that notepad just writes an ASC(13) carriage return for each
line break rather than the line feed/carriage return ASC(13)ASC(10)
combination (or is it the other way around?). When you save your file
in MS Notepad, the line terminator that is compatible with your other
applications is substituted into each of your file's original line
terminators that aren't compatible with your other applications.
BTW it could also be that the sequence of the terminator characters is
causing the problem (ie 10 followed by 13 or 13 followed by 10)
Andy
John Hopper wrote:
Using code below to create an xml file, how do I specifiy utf-8 encoding in
the root element, ie create "<?xml version="1.0" encoding="utf-8"?>
Dim xmlWriter As New
XmlTextWriter("C:\inetpub\wwwroot\rss2\20061019\te st.xml", Nothing)
See the documentation
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlXmlTextWriterClassctorTopic3.asp>
you need to pass in the encoding e.g.
New XmlTextWriter("C:\inetpub\wwwroot\rss2\20061019\te st.xml",
System.Text.Encoding.UTF8)
--
Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/
Hello,
Using code below to create an xml file, how do I specifiy utf-8 encoding in
the root element, ie create "<?xml version="1.0" encoding="utf-8"?>
Thanks!
-------------------------------------------
Dim xmlWriter As New
XmlTextWriter("C:\inetpub\wwwroot\rss2\20061019\te st.xml", Nothing)
xmlWriter.Formatting = Formatting.Indented
With xmlWriter
.WriteStartDocument()
.WriteStartElement("rss")
.WriteAttributeString("version", "2.0")
.WriteStartElement("channel")
.WriteElementString("title", "caseNumber" & ": " & "caseName")
.WriteElementString("link", "link")
.WriteElementString("description", "caseName")
.WriteElementString("lastBuildDate", Now.ToString("ddd, dd MMM
yyyy hh:mm:ss") & " GMT") '<<<<<<<<<<<<<<<<<<<<<<<<<<<
'.WriteElementString("pubDate", caseAdded.ToString("ddd, dd MMM
yyyy hh:mm:ss") & " GMT") 'Now())
.WriteStartElement("item")
.WriteElementString("title", "description")
.WriteStartElement("guid")
.WriteAttributeString("isPermaLink", Nothing, "false")
.WriteString(Guid.NewGuid.ToString)
.WriteEndElement()
' .WriteElementString("title", description)
.WriteElementString("description", "caseNumber")
.WriteElementString("link", "link")
'.WriteElementString("pubDate", dateModified & " 12:00:00 GMT")
'Now().ToString) <---------------------------change
.WriteElementString("pubDate", Now().ToString("ddd, dd MMM yyyy
hh:mm:ss") & " GMT")
.WriteEndElement() '<<<<<<<<<<<<<<<<<<<<<
.WriteEndElement()
.WriteEndElement()
.WriteEndDocument()
.Flush()
.Close()
End With
xmlWriter = Nothing
you can also check this:
xmlWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
In that case there is no need to use
xmlWriter.WriteStartDocument()
Posted from http://www.topxml.com/renntp using reNNTP: the website based NNTP reader.
you can also check this:
xmlWriter.WriteProcessingInstruction("xml", "version='1.0'
encoding='UTF-8'");
In that case there is no need to use
xmlWriter.WriteStartDocument()
May be this is helpful to u.
---------------------------------- http://community.ihostasp.net
ASP.NET Developer Community This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Amittai Aviram |
last post by:
This XHTML 1.0 Strict page --
http://www.studiolirico.org/docs/settimana2003.html
has a bilingual title in Italian and English. The principle language of the
page is Italian, so the <html> tag...
|
by: Pascal.Schicht |
last post by:
Hi!
in my Application i have the need to get an XML Declaration without the
Encoding Tag.
Actual i get this declaration: <?xml version="1.0" encoding="utf-8"?>
I need this: <?xml...
|
by: jmhmaine |
last post by:
During the course of development cycle I receive HTML files from designers
that use Macs and PCs, but use tools other then Visual Studio. So these files
sometimes are not UTF-8 Encoded.
I see...
|
by: Mark |
last post by:
Hi...
Just noticed something odd... In old ASP if you had query parameters that
were invalid for their encoding (broken utf-8, say), ASP would give you back
chars representing the 8-bit byte...
|
by: Chris McDonough |
last post by:
ElementTree's XML serialization routine implied by tree._write(file,
node, encoding, namespaces looks like this (elided):
def _write(self, file, node, encoding, namespaces):
# write XML to file...
|
by: Bob |
last post by:
Hi
Need to produce a Doc with no encoding info.
Is there anyway of doing this?
Thanks
Bob
i.e.
<?xml version=\"1.0\" ?>
|
by: Neil Cerutti |
last post by:
How do I cope with faulty encoding settings?
I'm writing an application that needs all internal character data
to be stored in iso-8859-1. It also must allow input and output
using stdin and...
|
by: UIVE |
last post by:
Hey there.
I have an .aspx page, where i have a pretty simple form on it. 2 text
input fields and a submit button. The action of the page is then
submitted to a different site which then handles...
|
by: hotani |
last post by:
I am attempting to pull info from an LDAP server (Active Directory),
but cannot specify an OU. In other words, I need to search users in
all OU's, not a specific one.
Here is what works:
con...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
| |