PC Review


Reply
Thread Tools Rate Thread

DataRow Prefix

 
 
occ
Guest
Posts: n/a
 
      23rd Nov 2009
Hi,

I have been trying to generate a xml file via typed datasets using the
writexml method. The xml I am after is
<?xml version="1.0" standalone="yes" ?>
- <bw:ABC xmlns:bw="http://tempuri.org/ABC.xsd">
- <bw:Employee>
<bw:EmployeeID>1</EmployeeID>
<bw:EmployeeName>John</EmployeeName>
</bw:Employee>
- <bw:Employee>
<bw:EmployeeID>2</EmployeeID>
<bw:EmployeeName>Peter</EmployeeName>
</bw:Employee>
</bw:ABC>

how ever when I run my code I get the following:

<?xml version="1.0" standalone="yes" ?>
- <bw:ABC xmlns:bw="http://tempuri.org/ABC.xsd">
- <bw:Employee>
<EmployeeID xmlns="http://tempuri.org/ABC.xsd">1</EmployeeID>
<EmployeeName xmlns="http://tempuri.org/ABC.xsd">John</
EmployeeName>
</bw:Employee>
- <bw:Employee>
<EmployeeID xmlns="http://tempuri.org/ABC.xsd">2</EmployeeID>
<EmployeeName xmlns="http://tempuri.org/ABC.xsd">Peter</
EmployeeName>
</bw:Employee>
</bw:ABC>

the csharp code looks like this

ABC bw = new ABC ();
bw.Prefix = "bw";

ABC.EmployeeDataTable employee = (ABC.EmployeeDataTable)bw.Tables
["Employee"];
employee.Prefix = "bw";

ABC.EmployeeRow employeeRow1 = employee.NewEmployeeRow
();

employeeRow1.EmployeeID = 1;
employeeRow1.EmployeeName = "John";
employee.AddEmployeeRow(employeeRow1);

ABC.EmployeeRow employeeRow2 = employee.NewEmployeeRow();
employeeRow2.EmployeeID = 2;
employeeRow2.EmployeeName = "Peter";
employee.AddEmployeeRow(employeeRow2);

bw.WriteXml("c:\\abc.xml");

how can I get rid of the xmlns attribute from the xml file and prefix
with bw.There is no prefix property for DataRow field.
 
Reply With Quote
 
 
 
 
Jani Järvinen [MVP]
Guest
Posts: n/a
 
      24th Nov 2009
Hi Occ,

> I have been trying to generate a xml file via typed datasets using the
> writexml method. ... [snip]
> how can I get rid of the xmlns attribute from the xml file and prefix
> with bw.There is no prefix property for DataRow field.


There's only so much the ready-made WriteXml method can go, but if you have
special requirements on the resultsing XML formatting, I suggest you take
either of these two routes: either output the XML by hand, or create an XSLT
transformation to come up with the required XML.

Outputting the XML by hand can be simple or complex depending on your
dataset structure, but given the XML you showed, I'd expect this to be a
straightforward operation. At least for me, it would take longer to come up
with the XSL transformation file, at least without tools.

On the other hand, if you are interested in the transformations, see here:

http://msdn.microsoft.com/en-us/library/8fd7xytc.aspx

Hope this helps!

--
Regards,

Jani Järvinen
C# MVP
Vantaa, Finland
E-mail: (E-Mail Removed)
Business: http://www.nimacon.net/
Personal: http://www.saunalahti.fi/janij/


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is DataRow[string] uses DataRow[int] and DataRow[int] much efficient than DataRow[string]? Ryan Liu Microsoft C# .NET 3 2nd Feb 2008 06:14 AM
Distinguish 2 situations when a DataRow in Detached state; Or why not make the data row intact after being added then removed from a dataRow collection? Ryan Liu Microsoft Dot NET 0 7th Jun 2006 03:04 PM
Distinguish 2 situations when a DataRow in Detached state; Or why not make the data row intact after being added then removed from a dataRow collection? Ryan Liu Microsoft C# .NET 0 7th Jun 2006 02:14 AM
create new DataRow, init fields, then set DataRow to UnChanged? Les Caudle Microsoft ADO .NET 2 4th May 2004 05:42 PM
Re: Casting Data.Datarow to a strongly typed datarow CJ Taylor Microsoft VB .NET 4 21st Apr 2004 08:09 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:54 AM.