VB 6.0 - xml header encoding declaration

Asked By bobby naderi
03-Nov-09 04:53 PM
building an xml generator in vb within excel, how can i get the encoding declaration to appear as the first line?

<?xml version="1.0" encoding="ISO-8859-1" ?>

re  re

03-Nov-09 10:26 PM

u can use WriteStartDocument for that encoding

also see this

http://support.microsoft.com/kb/317169

I guess the answer above points to VB.Net and not VB 6.0.  I guess the answer above points to VB.Net and not VB 6.0.

04-Nov-09 01:33 PM
In VB 6.0, you would write the XML Declaration like this:

Dim memory_stream As New MemoryStream
Dim xmlTextWriter As New XmlTextWriter(memory_stream, System.Text.Encoding.UTF8)
' Write the XML declaration.
xmlTextWriter.WriteStartDocument(True)

And if you happen to migrate to VB.Net anytime,  you could use the XMLDocument class's CreateXmlDeclaration method. Sample snippet provided below.

//Create or Load the Xml Document.
XmlDocument xmlDoc = new XmlDocument();
//Create an XML declaration. 
XmlDeclaration xmlDeclartion = xmlDoc.CreateXmlDeclaration("1.0",null,null);
Create New Account
help
StringWriterWithEncoding in vb net I am using socket to connect to remote host and send the data in I would like to convert it to String (the xml) and pass it to my class. I am getting an error "StringWriterWithEncoding" not defined. My question is where StringWriterWithEncoding object is String Dim myxml = New System.Xml.XmlTextWriter(New StringWriterWithEncoding(sb, System.Text.Encoding.ASCII)) myxml.WriteStartDocument() myxml.WriteStartElement("REQUEST") myxml.WriteStartElement("START_TASK") myxml.WriteAttributeString("TASK_NAME", TextBox1.Text) myxml.WriteAttributeString("TASK_INSTANCE_NAME", TextBox2 sb.ToString() Thanks, Nirmala library as "StringWriterWithEncoding" unless of course you have created a custom class deriving from StringWriter. I think you need to go back and look at whereever you New(String, Encoding) I would guess whoever wrote the code you are using created a class derived from TextWriter. You can simply create the Xml using a memory stream and specify
Stringbuilder / XmlTextWriter does not allow Encoding override .NET Framework VB.net I need to create xml using Windows-1252 encoding. . . So I try. . . Dim sw to string And System.IO.StringWriter cannot be converted to System.IO.Stream Any ideas ? VB.NET Discussions JavaScript (1) StringWriter (1) WriteStartDocument (1) WriteStartElement (1) WriteEndDocument (1) MemoryStream (1) Encoding (1) Xml (1) If you want the property, here is a .NET 2.0 C# example, hopefully you can transcribe that to VB yourself: public class StringWriterWithEncoding : StringWriter { private Encoding MyEncoding; public StringWriterWithEncoding(Encoding encoding) : base() { MyEncoding = encoding; } public override Encoding Encoding { get { return MyEncoding; } } } then use that class as e.g. StringWriterWithEncoding stringWriter = new StringWriterWithEncoding(Encoding.GetEncoding(1252)); using (XmlWriter xmlWriter = XmlWriter.Create stringWriter)) { xmlWriter.WriteStartDocument(); xmlWriter.WriteStartElement("root"); xmlWriter.WriteElementString("foo", "bar"); xmlWriter.WriteEndDocument(); } Console.WriteLine(stringWriter.ToString()); which outputs e.g. - - Martin Honnen - -- MVP XML http: / / JavaScript.FAQTs.com / The XmlWriterSettings class only exists in framework 2.0. - - Göran Andersson _ __ __ http: / / www.guffa.com keywords: Stringbuilder
yahoo login through vb.net code Please help me I am a new vb.net programmer after getting suggestion from vb.net gurus from this forums I have made it and fetching data from yahoo finance messages. http: / / help.yahoo.com / l / us / yahoo / mail / original / mailplus / pop / pop-14.html ' VB Dim m As MailMessage = New MailMessage m.From = New MailAddress("you@yahoo.com", "Your Name to persist in your "old ways", I guess I can't help you! The XmlTextWriter class, which derives from XmlWriter, writes XML to a file, console, stream, and other output types whether it follows the W3C rules. Methods in the XmlWriter also come in pairs; the WriteStartDocument and WriteEndDocument , WriteStartElement and WriteEndElement , and the WriteStartAttribute and WriteEndAttribute method pairs. Using these methods lot, here is the code for a rewritten Yahoo Stock Quote webservice, using the XmlTextWriter class, and which does another neat trick that I like, returns a DataSet directly from the IO; using System.Text; using System.Xml; namespace YahooMultiQuote { [WebService(Namespace = "http: / / localhost / YahooMultiQuote / " )] public class Service1 : System.Web.Services.WebService { public Service1() { InitializeComponent(); } #region Component Designer generated code private IContainer
projects: A BizTalk project containing: A message schema for the An orchestration A pipeline A VB.Net class library project containing: A custom pipeline component that does the debatching of the incoming message into smaller messages. A VB Net class library containing: The schema classes derived from the xsd in the BizTalk project In addition shown in the following screensot A dd the SchemaClasses Project Next we create the schema class file from the CompanyStats.xsd. Open a command prompt and execute the following command: Xsd.exe < path_to_CompanyStats.xsd > -c –l:VB This will produce the CompanyStats.vb class file. This needs to be added to the project so add a new VB class