Re: Web service to return xml file



Hi Steven,
I have used your code example to create web methods that return xml files,
and they work perfectly fine.
Thank you for your assistance,
Tom Pedersen
""Steven Cheng"" <stcheng@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:RoDAENTKJHA.4620@xxxxxxxxxxxxxxxxxxxxxxxxx
Hi Tom,

Nice to hear from you.

AS for LINQ to XML, it can help conveniently generated xml document from a
certain object collection together with LINQ to object. Are you using
VB.NET or c#(vb.net has provided more advanced support on LINQ to XML).

Here I use a SQLServer data accessing case t demonstrate (should be the
same code logic for Access Database). I use datareader to retrieve data
and LINQ to XML to compose the XML document from the data:

=============================
private static void Run_LINQ()
{
string connstr = "Data Source=localhost;Initial
Catalog=testdb;Integrated Security=True";
string sqltxt = "select [id],[name] from edit_table";


using (SqlConnection conn = new SqlConnection(connstr))
{
conn.Open();

SqlCommand comm = new SqlCommand(sqltxt, conn);

IDataReader reader = comm.ExecuteReader();

XDocument doc = new XDocument();

XElement root = new XElement("root");

while (reader.Read())
{
root.Add(
new XElement("Item",
new XElement("id", reader["id"].ToString()),

new XElement("name",reader["name"].ToString())

)
);

}

reader.Close();

doc.Add(root);

doc.Save("output.xml");
}

}
=====================================

You can see that LINQ to XML code somewhat make the xml document/element
generation more visualized/readable.

If you have any further question, welcome to let me know. I'll also update
you in the newsgroup.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx


--------------------
From: "TompIfe" <tpskonto@xxxxxxxxxxxxxxxx>
Subject: Web service to return xml file
Date: Mon, 29 Sep 2008 10:48:41 +0200
Hi,
I have a web service that reads data from an Access database using
datareader and place the data in an array that
the web method returns.
Now, I want to make the web service also to return an xml file with the
data.
How do I best proceed?
Best regards,
Tom










.



Relevant Pages

  • Re: xml in plain text file on heavy load.
    ... even if the XML file is magically and perfectly ... I want to emphasize that IIS would never be caching that XML file on its own ... Application is NOT synchronizing access to your ASP pages. ...
    (microsoft.public.inetserver.iis)
  • Re: TAPI 3.0 call attached data
    ... The format of the Call Attached Data is XML. ... XML file with CallAttchedData represents one or multiple data lists ... Root element is CallAttachedData. ... version CDATA #FIXED "1.0" ...
    (microsoft.public.win32.programmer.tapi)
  • Re: XML parser and writer
    ... them on a calendar. ... Therefore I will need to both easily parse and write new XML files. ... why not some database technology? ... an advanced user can edit the XML file directly at ...
    (comp.lang.java.programmer)
  • Re: Zooming Out: The Larger Issue
    ... XML file or a binary file (smaller and faster to serialize deserialize, ... On startup of your app you could just check if the xml / binary file exists ... datarow = the container of one or more datacolumns wich in there turn hold ...
    (microsoft.public.dotnet.languages.vb)
  • Re: XmlTextReader or XmlDocument or SQLCE
    ... I wouldn't really call it "unrealistic expectations", ... I would love to see a 1 second response time ... reading a single node from a 200k XML file on any version of CF running on ... > As to saving XML file after each change, ...
    (microsoft.public.dotnet.framework.compactframework)