Dear Pals,
I am creating a XML document through this code:
Imports System
Imports System.IO
Imports System.Xml
Imports System.Text
Module Module1
Sub Main()
Dim textWriter As New XmlTextWriter("e:\Emp.xml", _
System.Text.Encoding.UTF8)
textWriter.Formatting = Formatting.Indented
textWriter.WriteDocType("Employees", Nothing, Nothing, Nothing)
textWriter.WriteComment("This file represents a fragment of Employees" & _
"database")
textWriter.WriteStartElement("Employees")
textWriter.WriteStartElement("Employee", Nothing)
textWriter.WriteElementString("FirstName", "John")
textWriter.WriteElementString("LastName", "Doe")
textWriter.WriteElementString("DateOfBirth", "08/09/1968")
textWriter.WriteElementString("DateOfJoining", "04/01/1992")
textWriter.WriteEndElement()
textWriter.WriteEndElement()
' Write the XML to file and close the textWriter
textWriter.Flush()
textWriter.Close()
Console.WriteLine("Press a key to exit.")
Console.ReadLine()
End Sub
End Module
Here is my output:
<!DOCTYPE Employees>
<!--This file represents a fragment of Employeesdatabase-->
<Employees>
<Employee>
<FirstName>John</FirstName>
<LastName>Doe</LastName>
<DateOfBirth>08/09/1968</DateOfBirth>
<DateOfJoining>04/01/1992</DateOfJoining>
</Employee>
</Employees>
Can anyone tell me how to add XML Declaration at the top of the document.
Thanks in Advance....
--
ThankZZZ,
SamuelSudhakarJ 1 3571
Dear SamuelSudhakarJ,
Add this to your code..
textWriter.WriteStartDocument(True)
It will create
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
on the top of your XML document.
for further reference, visit this link.
ms-help://MS.NETFrameworkSDK/cpref/html/frlrfSystemXmlXmlTextWriterClassWriteStartDocument Topic.htm
--
Thanks & Regards,
John Paul. A
MCP
"SamuelSudhakarJ" wrote: Dear Pals, I am creating a XML document through this code:
Imports System Imports System.IO Imports System.Xml Imports System.Text
Module Module1 Sub Main() Dim textWriter As New XmlTextWriter("e:\Emp.xml", _ System.Text.Encoding.UTF8) textWriter.Formatting = Formatting.Indented textWriter.WriteDocType("Employees", Nothing, Nothing, Nothing) textWriter.WriteComment("This file represents a fragment of Employees" & _ "database") textWriter.WriteStartElement("Employees") textWriter.WriteStartElement("Employee", Nothing) textWriter.WriteElementString("FirstName", "John") textWriter.WriteElementString("LastName", "Doe") textWriter.WriteElementString("DateOfBirth", "08/09/1968") textWriter.WriteElementString("DateOfJoining", "04/01/1992") textWriter.WriteEndElement() textWriter.WriteEndElement()
' Write the XML to file and close the textWriter textWriter.Flush() textWriter.Close() Console.WriteLine("Press a key to exit.") Console.ReadLine() End Sub End Module
Here is my output:
<!DOCTYPE Employees> <!--This file represents a fragment of Employeesdatabase--> <Employees> <Employee> <FirstName>John</FirstName> <LastName>Doe</LastName> <DateOfBirth>08/09/1968</DateOfBirth> <DateOfJoining>04/01/1992</DateOfJoining> </Employee> </Employees>
Can anyone tell me how to add XML Declaration at the top of the document. Thanks in Advance....
-- ThankZZZ, SamuelSudhakarJ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Alexander Zatvornitskiy |
last post by:
Hello All!
I'am novice in python, and I find one very bad thing (from my point of view) in
language. There is no keyword or syntax to declare variable, like 'var' in
Pascal, or special syntax in C. It can cause very ugly errors,like this:
epsilon=0
S=0
while epsilon<10:
S=S+epsilon
|
by: newmans |
last post by:
Perhaps one of the experts can straighten me out on this point...
In Bjarne Stroustrup's book 'The C++ Programming Language' 3rd Edition,
section 4.9, indicates that
typedef complex<short> Point;
is not only a declaration, but also a definition.
The ISO/IEC 14882:2003(E) standard states in section 3.1 clause 2 that
|
by: Kobu |
last post by:
My question is about the use and meaning of the terms "declaration" and
"definition" as it pertains to the C language.
I've read sources that mix the two up when talking about such things as
setting aside storage for an object, defining/declaring a struct, parts
of a function, referencing an external variable in another module.
...
|
by: venky |
last post by:
Hi
main() {
int x; /* it declaration or defination??*/
}
|
by: nospam_timur |
last post by:
Let's say I have two files, myfile.h and myfile.c:
myfile.h:
int myfunction(int x);
myfile.c:
#include "myfile.h"
| |
by: Jess |
last post by:
Hello,
I was told that if I declare a static class constant like this:
class A{
static const int x = 10;
};
then the above statement is a declaration rather than a definition.
As I've *defined* "x"'s value to be 10, isn't above statement a
|
by: Alan |
last post by:
Does a template class declaration, like
template <class T>
have to come immediately prior to the declaration of the function,
e.g.,
T do_something (T something)
{ . . . }
that uses it?
|
by: vaib |
last post by:
hi to all.i'd like to know the actual difference between variable
declaration and definition.it would be very helpful if anyone out
there wud help me out with this thing.i'm writing here after here
after a long time since people here also helped me out with my lexer.
thanking in anticipation.
|
by: WaterWalk |
last post by:
I find friend declaration just very tricky. I tried the following
examples on both MingW(gcc 3.4.2) and VC++ 2005. The results are
surprising.
Example1:
namespace ns1
{
class Test
{
friend void func()
|
by: tvnaidu |
last post by:
I am using Three pthread functions below, I got ISO error, then I declared int variable called val123, then I assigned, but still I am getting error, any idea?. also I included pthread.h. compiling in Linux with GCC.
pthread_cond_signal(&(receiverConf->receive_q_cond));
pthread_cond_destroy(&(receiverConf->receive_q_cond));...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |