Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML and .net

Status
Not open for further replies.

tirbine

Programmer
Mar 13, 2003
2
US
Here's what I've got --
Application using three tier structure with an SQL Server backend, C# Middle tier, and aspx/vb.net front end. Now, I have preformed letters that I want to generate and some of the content that needs to be added to the letter is going to need to come from a database and some of it from user selected values.
Is there a way to not only get the values taht are needed from the database to turn them into XML but also get teh selected values from the users form and turn them into XML values so that it can all be used in an XSL sheet?
Thanks.
 
Is there a way to not only get the values taht are needed from the database to turn them into XML but also get teh selected values from the users form and turn them into XML values so that it can all be used in an XSL sheet?

Yes. Use ADO.NET commands to retrieve the data from the database. You'll typically have a SqlDataReader or OleDbDataReader object with your row contents. You would then load your template letter from somewhere, and replace the embedded tags with the values from your DataReader.

Once you have your customized letter you then must send it to your UI, and it sounds like you're using XML for that. You'll need to add the letter to a CData node in order to preserve whitepace.
Code:
XmlDocument MyDoc = new XmlDocument();
XmlNode RootNode = MyDoc.CreateElement("RootNodeName");
MyDoc.AppendChild(RootNode);

XmlNode LetterNode = MyDoc.CreateCDataSection(StringWithLetterInIt);
RootNode.AppendChild(LetterNode);

string XMLString = MyDoc.InnerXml;
Afterwards, XMLString will contain your XML that has your document in it. You can then pass it up to your UI components to be transformed & shown to the user.

Hope this gets you started.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top