Click here to Skip to main content
15,917,005 members
Home / Discussions / XML / XSL
   

XML / XSL

 
QuestionYet another special character problem Pin
Arrun26-May-06 13:12
Arrun26-May-06 13:12 
AnswerRe: Yet another special character problem [modified] Pin
George L. Jackson26-May-06 17:35
George L. Jackson26-May-06 17:35 
GeneralRe: Yet another special character problem [modified] Pin
Arrun27-May-06 1:13
Arrun27-May-06 1:13 
GeneralRe: Yet another special character problem [modified] Pin
George L. Jackson27-May-06 6:59
George L. Jackson27-May-06 6:59 
QuestionProblem Writing & URGENT PLS HELP Pin
Arrun26-May-06 9:48
Arrun26-May-06 9:48 
AnswerRe: Problem Writing & URGENT PLS HELP Pin
George L. Jackson26-May-06 17:37
George L. Jackson26-May-06 17:37 
QuestionHelp me for the use of AJAX in ASP Pin
Jesal Rana25-May-06 22:39
Jesal Rana25-May-06 22:39 
QuestionCode Generator that writes code to generate and XML doc structure? [modified] Pin
Josh Blair25-May-06 6:59
Josh Blair25-May-06 6:59 
Hello,

Has anyone ever seen/created such an animal?

I'm looking for a sample of a code generator that will generate code (preferably one that uses C# and the XMLTextWriter) to create an XML document structure based on an XML file as input.

I have to build some classes that allow me to generate some very complex/large/nasty XML documents for use in B2B exchange of data (like invoices, orders, etc.). A third party has dictated the structure and provided example XML documents. Instead of hand coding these classes, I'd like to be able to automatically generate them by using these example XML documents as input. This seems like a fairly easy task but I haven't sun across a demonstration of this yet.

An Example XML file (contents):
===============================

<myRootNode>
<myChildNode1>
<myChildNode2 myAttribute1="test"/>
. . .
</myChildNode1>
. . .
</myRootNode>

Example output from the code generator that takes the path of the xml file above (this is merely a simple example):
==================================================

// instantiate XmlTextWriter over file stream using UTF-8
XmlTextWriter tw = new XmlTextWriter(fileName, Encoding.UTF8);

// specify serialization details
tw.Formatting = Formatting.Indented;
tw.Indentation = 8;
tw.QuoteChar = '\"';

// No need for a start element
//tw.WriteStartDocument();

tw.WriteStartElement("myRootNode");

tw.WriteStartElement("myChildNode1");

tw.WriteStartElement("myChildNode2");

tw.WriteAttributeString("", "myAttribute1", "", "test");

tw.WriteEndElement(); // myChildNode2

tw.WriteEndElement(); // myChildNode1

tw.WriteEndElement(); // myRootNode

// No need for a start element
//tw.WriteEndDocument();

// close the stream
tw.Close();

Thanks for your time and input,

Josh Blair
Evergreen, CO

-- modified at 13:00 Thursday 25th May, 2006
AnswerRe: Code Generator that writes code to generate and XML doc structure? [modified] Pin
led mike25-May-06 7:07
led mike25-May-06 7:07 
GeneralRe: Code Generator that writes code to generate and XML doc structure? [modified] Pin
Josh Blair25-May-06 7:19
Josh Blair25-May-06 7:19 
GeneralRe: Code Generator that writes code to generate and XML doc structure? [modified] Pin
led mike25-May-06 19:54
led mike25-May-06 19:54 
GeneralRe: Code Generator that writes code to generate and XML doc structure? [modified] Pin
Josh Blair26-May-06 6:51
Josh Blair26-May-06 6:51 
GeneralRe: Code Generator that writes code to generate and XML doc structure? [modified] Pin
led mike26-May-06 7:04
led mike26-May-06 7:04 
GeneralRe: Code Generator that writes code to generate and XML doc structure? [modified] Pin
Josh Blair26-May-06 7:42
Josh Blair26-May-06 7:42 
GeneralRe: Code Generator that writes code to generate and XML doc structure? [modified] Pin
Josh Blair26-May-06 8:21
Josh Blair26-May-06 8:21 
GeneralRe: Code Generator that writes code to generate and XML doc structure? Pin
led mike26-May-06 8:59
led mike26-May-06 8:59 
GeneralRe: Code Generator that writes code to generate and XML doc structure? Pin
led mike26-May-06 8:32
led mike26-May-06 8:32 
GeneralRe: Code Generator that writes code to generate and XML doc structure? Pin
Josh Blair26-May-06 10:46
Josh Blair26-May-06 10:46 
AnswerRe: Code Generator that writes code to generate and XML doc structure? Pin
Dustin Metzgar26-May-06 7:42
Dustin Metzgar26-May-06 7:42 
GeneralRe: Code Generator that writes code to generate and XML doc structure? Pin
Josh Blair26-May-06 8:28
Josh Blair26-May-06 8:28 
GeneralRe: Code Generator that writes code to generate and XML doc structure? Pin
Dustin Metzgar26-May-06 8:34
Dustin Metzgar26-May-06 8:34 
GeneralRe: Code Generator that writes code to generate and XML doc structure? Pin
Josh Blair26-May-06 10:08
Josh Blair26-May-06 10:08 
GeneralRe: Code Generator that writes code to generate and XML doc structure? Pin
Dustin Metzgar26-May-06 10:44
Dustin Metzgar26-May-06 10:44 
Questionxml content problem?????? [modified] Pin
Small Rat24-May-06 17:02
Small Rat24-May-06 17:02 
QuestionXSD Schema modeling ( please help) Pin
erikkl200023-May-06 18:48
erikkl200023-May-06 18:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.