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

generate xml document

Hello!

Is possible to generate an xml document in any way or is the only way to
write it manually.
We can assume that we have all the information for the xml document.

//Tony
Aug 13 '08 #1
7 1289
Lots of ways... how do you currently have the data, and what is it?
That will determine the most suitable option.

Marc
Aug 13 '08 #2
On Aug 13, 10:47*am, Marc Gravell <marc.grav...@gmail.comwrote:
Lots of ways... how do you currently have the data, and what is it?
That will determine the most suitable option.
And also, which version of the framework are you using? LINQ to XML is
lovely, but only if you're using .NET 3.5...

Jon
Aug 13 '08 #3
And also, which version of the framework are you using? LINQ to XML is
lovely, but only if you're using .NET 3.5...
And where is the data coming from... for example, SQL/XML in SQL
Server 2005 / 2008 can work very well via "FOR XML PATH" in TSQL.

Marc
Aug 13 '08 #4
Hello!

Assume I have SQL server 2005 database where I want some data to be inserted
into a Xml document.
//Tony

"Marc Gravell" <ma**********@gmail.comskrev i meddelandet
news:9d**********************************@y38g2000 hsy.googlegroups.com...
And also, which version of the framework are you using? LINQ to XML is
lovely, but only if you're using .NET 3.5...

And where is the data coming from... for example, SQL/XML in SQL
Server 2005 / 2008 can work very well via "FOR XML PATH" in TSQL.

Marc

Aug 13 '08 #5
Again, that doesn't give much away... if you are talking about small
changes to xml *already stored in an xml column*, then you can do this
at the server in TSQL (see link below) and avoid the IO cost of moving
the data. If you want to get data *out* of the SQL Server as xml, then
"FOR XML PATH" is your friend. Neither of these involve C#, so I won't
go into detail here...

If you are reading simple data from the server (perhaps via LINQ-to-
SQL) then you might want to do some work in C# - but as Jon correctly
observes, this depends on which framework you are using. With 2.0/3.0
you have XmlDocument and XmlWriter, but 3.5 introduces XDocument and
some language enhancements which make it trivial to construct xml in
various shapes.

Perhaps a simpified (but concrete) example would make things
clearer...? Can you explain more what you want to happen?

TSQL/XML link: http://msdn.microsoft.com/en-us/library/ms345117.aspx

Marc
Aug 13 '08 #6
Hello!

I just trying to learn some basic Xml so I have no specific task that I want
to accomplish.

//Tony

"Marc Gravell" <ma**********@gmail.comskrev i meddelandet
news:48**********************************@34g2000h sh.googlegroups.com...
Again, that doesn't give much away... if you are talking about small
changes to xml *already stored in an xml column*, then you can do this
at the server in TSQL (see link below) and avoid the IO cost of moving
the data. If you want to get data *out* of the SQL Server as xml, then
"FOR XML PATH" is your friend. Neither of these involve C#, so I won't
go into detail here...

If you are reading simple data from the server (perhaps via LINQ-to-
SQL) then you might want to do some work in C# - but as Jon correctly
observes, this depends on which framework you are using. With 2.0/3.0
you have XmlDocument and XmlWriter, but 3.5 introduces XDocument and
some language enhancements which make it trivial to construct xml in
various shapes.

Perhaps a simpified (but concrete) example would make things
clearer...? Can you explain more what you want to happen?

TSQL/XML link: http://msdn.microsoft.com/en-us/library/ms345117.aspx

Marc

Aug 13 '08 #7
Then here's a very simple LINQ-to-XML example; anything more really
needs a specific question...

Marc

var data = new[] {
new {Name = "Fred", Age = 25},
new {Name = "Jo", Age = 11},
new {Name = "Sally", Age = 41}
};

var doc = new XDocument(
new XElement("xml",
new XAttribute("created", DateTime.Today),
from person in data
select new XElement("person",
new XAttribute("name", person.Name),
new XAttribute("age", person.Age))));

string xml = doc.ToString();
Aug 13 '08 #8

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

Similar topics

5
by: Dario de Judicibus | last post by:
I am trying to generate an XML file to be shown in IE by javascript. My code looks like top.x = window.open('','MyXML') ; top.x.document.write('<?xml version="1.0" encoding="ISO-8859-1" ?>') ;...
2
by: soundarya | last post by:
I have a UI consisting of four fields - username,password,date of birth,location. I need to read the data from the textboxes and generate a xml document. Can you please explain the steps followed...
3
by: Brian Kwan | last post by:
Project Description: Develop a web application to help manage sale operations. There is a function that to generate a report using data in database, which is a Word document on server and let user...
2
by: Delmar | last post by:
I need to build Web Application that will generate a client to execute some operations. Each client has running silent application. Maybe somebody can advice me what can I do ? Thank you.
4
by: sysxperts | last post by:
Hi, I have a mail server that generates archives in a directory for every message sent or received and each archive has an associated XML file with <sender>, <receiver>, <subject> and other...
3
by: joshblair | last post by:
Hello, Has anyone ever seen or created such a code generator? I'm looking for a sample of a code generator that will generate code (preferably one that uses C# and the XMLTextWriter) to create...
0
by: taylorjonl | last post by:
I am having a problem generating some soap proxies dynamically using almost the exact same code as in the MSDN sample. ...
5
by: =?Utf-8?B?a3Jpcw==?= | last post by:
I created a simple webservice .asmx on Visual Studio 2005. As I plan to deploy it to Sharepoint Portal 2003, I copied asmx to \web server extensions\60\ISAPI directory of the server, where all...
21
by: Grant Edwards | last post by:
I need to be able to generate a PDF report which consists mostly of vector images (which I can generate as encapsulated Postscript, PDF, or SVG). What I need is a way to combine these figures...
3
by: cleary1981 | last post by:
Hi, I know how to generate xml from php but is there an easier way to generate xml from my code? <?php $quote=$_GET; //echo $quote; require "config.php"; $q1 = mysql_query("SELECT * FROM...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.