473,385 Members | 1,536 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,385 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 1296
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
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
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...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.