| Author |
How to generate empty XML from XSD
|
|
| Stefano 2005-03-21, 4:36 am |
| Hi all,
I defined a XML Schema... so I've a .xsd file.
I defined the schema using "default" attribute... for example:
<xs:element name="color" type="xs:string" default="red"/>
Now, I would like to generate an empty XML file, from the XML Schema.
How can I do that?
Thanks.
Bye
| |
| Ernest Griffin 2005-03-22, 11:24 pm |
| The easiest is the use of BizTalk (If you have it), you can XML editor to
generate test data against your xsd. Otherwise you can use MS Access to
import your schema (XSD) into a table. Take that table and export it to an
xml file and you will have an empty XML file based on your xsd.
To err is human
To really screw up
Requires a computer
Ernie Griffin
A Plan without Action is a Daydream
Action without a Plan is a Nightmare
| |
| Stefano 2005-03-23, 7:22 am |
| I need to programmatically generate the XML (from JavaScript and .NET)
So, not using tools.
Thank you anyway
Bye
--
Stefano Giannone
MCP .NET
http://www.giasoft.it
"Ernest Griffin" <nospam@devdex.com> ha scritto nel messaggio
news:Oo30e.47556$5T6.21240@bignews4.bellsouth.net...
> The easiest is the use of BizTalk (If you have it), you can XML editor to
> generate test data against your xsd. Otherwise you can use MS Access to
> import your schema (XSD) into a table. Take that table and export it to
an
> XML file and you will have an empty XML file based on your xsd.
>
> To err is human
> To really screw up
> Requires a computer
>
> Ernie Griffin
>
> A Plan without Action is a Daydream
> Action without a Plan is a Nightmare
| |
| Ernest Griffin 2005-03-25, 6:34 pm |
| Sorry it took so long to get back to you.
The following is a good way to do it.
I am not saying it is the best but It has worked for
me in the past.
System.Data.DataSet ds = new DataSet();
ds.ReadXmlSchema(@"C:\myxsd.xsd");
DataRow dr = ds.Tables[0].NewRow();
int i = 0;
foreach (DataColumn dc in ds.Tables[0].Columns)
{
dr[i]="";
i++;
}
ds.Tables[0].Rows.Add(dr);
ds.WriteXml(@"C:\myXsd.xml");
| |
| Stefano 2005-03-30, 12:08 am |
| This is not what I'm looking for (in this case the xsd represents a
DataSet...)
Thank you anyway.
Bye
--
Stefano Giannone
MCP .NET
http://www.giasoft.it
"Ernest Griffin" <nospam@devdex.com> ha scritto nel messaggio
news:px_0e.65293$Q83.43902@bignews5.bellsouth.net...
> Sorry it took so long to get back to you.
> The following is a good way to do it.
> I am not saying it is the best but It has worked for
> me in the past.
>
> System.Data.DataSet ds = new DataSet();
> ds.ReadXmlSchema(@"C:\myxsd.xsd");
> DataRow dr = ds.Tables[0].NewRow();
> int i = 0;
> foreach (DataColumn dc in ds.Tables[0].Columns)
> {
> dr[i]="";
> i++;
> }
> ds.Tables[0].Rows.Add(dr);
> ds.WriteXml(@"C:\myXsd.xml");
>
>
>
|
|
|
|
| Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |