Last post Aug 19, 2011 08:46 PM by Decker Dong - MSFT
Aug 17, 2011 02:09 PM|webchetan|LINK
Hello Friends- I am trying to create an API XML which has data coming from MySQL database. I am trying to acheive something like below.
<api xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<news xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" state="Trial">
<headline>Google buys Motorola</headline>
<headline>Apple Macbook Air</headline>
Aug 17, 2011 09:35 PM|webchetan|LINK
Can someone please share some thoughts here.
Aug 18, 2011 05:41 AM|Samarendra|LINK
Check This one this may help you :
Aug 18, 2011 09:12 AM|webchetan|LINK
This doesn't seem related to what I need! Above all its not in ASP.NET.
Anyone with expertise on this would be a great help.
Aug 18, 2011 10:08 PM|Decker Dong - MSFT|LINK
It seems that you want to create an xml file with the help of the data contents from MySQL? Am I right?
If yes, I'd like to offer you two ways:
1) Using XDocument+ADO.NET——(manually)
Just use SqlDataReader+SqlCommand to read line by line, and in the foreach loop, plz create dynamically XElement and add them to the root of your XDocument, and then call "SaveAs" method of the XDocument class instance (For more about XDocument, see samples
2) You should use MySqlDataAdapter+Fill method to fetch all the data contents into a DataTable, and then use WriteXml dreictly to write an xml-based file, which is very easy. And you can do modifications based on that.
Hope either or both of them help you a lot, and don't forget to install MySqL supporting files or dll in VS, because Vs doesn't support them directly. Download at:http://dev.mysql.com/downloads/connector/net/
Aug 19, 2011 05:17 PM|webchetan|LINK
Hi Decker - Appreciate your reply! Well I am using LinqConnect (DevArt's) to querry data using LINQ technology against MySQL Database. WHich runs great. My question is if you read my original post. I am planning on doing Routing considering the way I want
the XML to render and appear on the browser.
I am doing routing using routedata method which is part of .NET frmaework 4.0 and was able to replica what i was trying to achieve in my original post. Now do I need to Serilaize the XML which I am creating using XDocument and XElement and which I write
it to the Memory Stream using XMLWriter.
Aug 19, 2011 08:46 PM|Decker Dong - MSFT|LINK
Hello webchetan again：）
I am planning on doing Routing considering the way I want the XML to render and appear on the browser.
I took you clearly—— you want to show the whole xml contents in the webform when inputting the "http://api.mydomain.com/eee83d24-906b-4736-91d9-1031621b79eb/news ". Yes?
If that so——Well, OK——I'd like to show your another sample.
public partial class WebForm1 : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
WebRequest request = WebRequest.Create("Your own URL of your address, which must return an xml result");
WebResponse resp = request.GetResponse();
StreamReader sr = new StreamReader(resp.GetResponseStream());
Response.ContentType = "text/xml";