Click here to Skip to main content
15,890,670 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi every body;

my XML Schema is like this :

XML
<?xml version="1.0" encoding="UTF-8"?>
<Letter xmlns="http://www.irica.com/ECE/1383-12/SendSchema">
  <Protocol Name="ECE" Version="1.01"/>
<Software SoftwareDeveloper="data from sql" Version="3.0" GUID="A62E7B29-3AE3-4E13-B15E-5E7E10247726" />
  <Sender Organization="data from sql" Code="A62E7B29-3AE3-4E13-B15E-5E7E10247726" Department="" Position="" Name=""/>
  <Receiver Organization="data from sql" Code="100003083" ReceiveType="Origin" Department="" Position="" Name=""/>
  <LetterNo>data from sql</LetterNo>
  <LetterDateTime ShowAs="gregorian">2010-01-18T08:21:40.0000000+03:30</LetterDateTime>
  <Subject>data from sql</Subject>
  <Priority Name="عادي" Code="1"/>


and I have these data for ex:
CSS
Software
SoftwareDeveloper:"";
Version:"";
.
Sender
Organization="";
.
.
LetterNo="":


how can I send these data to that xml in asp?
Posted
Updated 16-Sep-14 0:48am
v3
Comments
Kornfeld Eliyahu Peter 16-Sep-14 4:31am    
Have you done anything so far? Please show some effort (search or code)! As is it ain't a question...
ChintanShukla 16-Sep-14 4:31am    
And what have you tried so far?
Angela 10293848 16-Sep-14 4:33am    
I dont know how can I send data to a xml file is not it clear?
ChintanShukla 16-Sep-14 4:58am    
What is your table structure? what is the XML format you expect?..Pls click on Improve Question and add more information.
Angela 10293848 16-Sep-14 4:59am    
I have updated my question

1 solution

There are different ways you can do this.

* Create a typed DataSet that reflects the XML structure.
Working with Datasets in Visual Studio[^]
If you load the XML file in Visual Studio, you can auto create a DataSet using the XML menu.

* You can use XML LINQ.
XDocument Class[^]
If you explore the classes XDocument, XElement, XAttribute etc. you will find many examples in MSDN.

Then of course you need to create an SQL query in order to get the data from the database.
Without knowing the structure of your tables, the only help I can give is this: SQL Tutorial[^]
 
Share this answer
 
v2
Comments
Angela 10293848 16-Sep-14 5:33am    
forget sth about sql imagine I have these strings in asp
Software
SoftwareDeveloper:"";
Version:"";
.
Sender
Organization="";
.
.
LetterNo="":
now how can I put them in above xml schema in asp?
thanks
George Jonsson 16-Sep-14 5:37am    
Please use the 'Improve question' thingy in order to update your question.
Angela 10293848 16-Sep-14 7:24am    
I found that how I can create it with below code
protected void Button1_Click(object sender, EventArgs e)
{
XDocument tree = new XDocument(
new XComment("This is a comment"),
new XElement("Letter",
new XElement("Protocol", new XAttribute("Name", Pname), new XAttribute("Version", Pname))
, new XElement("Software", new XAttribute("SoftwareDeveloper", Pname), new XAttribute("Version", Pname), new XAttribute("GUID", Pname))
, new XElement("Sender", new XAttribute("Organization", Pname), new XAttribute("Code", Pname), new XAttribute("Department", Pname), new XAttribute("Position", Pname), new XAttribute("Name", Pname))

)

);


}


now how can I save it ?finally I want to attach this xml in an email?
George Jonsson 16-Sep-14 7:31am    
Have you tried tree.Save(@"C:\SomeFolder\SomeFileName.xml"); ?
Angela 10293848 16-Sep-14 7:35am    
Yes George it works but I want to save it on server side not in client side

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900