Hmm... can't make it work...
I'm also in doubt where to put the code
I'm typing the dataset manually and using a datareader to fill it.
Main Topics
Browse All TopicsHere is a simple webservice returning a dataset with a table (MyTable1) containing one coloumn (ID) as xml.
I would like to assign some attributes to both 'MyTable1' and 'ID'.
How to do that
See below - sourcecode, existing xml response, desired xml response:
Hope you get the point - or ask me to clarify... Thanks;-)
Sourcecode:
--------------------------
[WebMethod]
public DataSet MyDataSet()
{
DataSet ds = new DataSet("MyDS");
DataTable dt = new DataTable("MyTable1");
dt.Columns.Add("ID");
ds.Tables.Add(dt);
DataRow datarow = ds.Tables["MyTable1"].NewR
datarow["ID"] = "Test";
ds.Tables["MyTable1"].Rows
return ds;
}
--------------------------
Xml response:
--------------------------
<?xml version="1.0" encoding="utf-8"?>
<DataSet xmlns="http://tempuri.org/
<xs:schema id="MyDS" xmlns="" xmlns:xs="http://www.w3.or
.........................
.........................
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-
<MyDS xmlns="">
<MyTable1 diffgr:id="MyTable11" msdata:rowOrder="0" diffgr:hasChanges="inserte
<ID>test</ID>
</MyTable1>
</MyDS>
</diffgr:diffgram>
</DataSet>
--------------------------
Desired xml response:
--------------------------
<?xml version="1.0" encoding="utf-8"?>
<DataSet xmlns="http://tempuri.org/
<xs:schema id="MyDS" xmlns="" xmlns:xs="http://www.w3.or
.........................
.........................
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-
<MyDS xmlns="">
<MyTable1 diffgr:id="MyTable11" msdata:rowOrder="0" diffgr:hasChanges="inserte
<ID attribute1="Content" attribute2="etc.">test</ID
</MyTable1>
</MyDS>
</diffgr:diffgram>
</DataSet>
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
just tested it and it works
--------------------------
[WebMethod]
public DataSet MyDataSet()
{
DataSet ds = new DataSet("MyDS");
DataTable dt = new DataTable("MyTable1");
dt.ExtendedProperties.Add(
dt.ExtendedProperties.Add(
DataColumn dc= new DataColumn("ID");
dc.ExtendedProperties.Add(
dt.Columns.Add(dc);
ds.Tables.Add(dt);
DataRow datarow = ds.Tables["MyTable1"].NewR
datarow["ID"] = "Test";
ds.Tables["MyTable1"].Rows
return ds;
}
// -- one more thing, it would help you a lot if you give your variables more readable name like myDataSet instead of
// -- ds,dt,dc,etc... of course thats only about prefence, but take my word, its very helpful =)
// -- create a column and set it as attribute
DataColumn myColumn = new DataColumn("AttributeColum
myColumn.ColumnMapping = MappingType.Attribute;
<Your DataTable>.Add(myColumn)
// -- create a DataRow and set its myColumn("AttributeColumn"
DataRow datarow = ds.Tables["MyTable1"].NewR
datarow["AttributeColumn"]
ds.Tables["MyTable1"].Rows
// -- it will add an attribute to your MyTable1 node -- >> AttributeColumn="Attribute
// -- btw, i've also noticed that creating a new row see below
// -- this creates a new MyTable1 Node instead of just adding an ID node to the existing MyTable1 Node
// -- adding a new row to the same table but when it is converted to XML, a new MyTable1 Node is created
// -- im not sure if you've noticed it already
DataRow datarow2 = ds.Tables["MyTable1"].NewR
datarow2["ID"] = "Test2";
ds.Tables["MyTable1"].Rows
Business Accounts
Answer for Membership
by: steelheart38Posted on 2005-08-26 at 06:24:24ID: 14760619
can you try this -->
.Add("Time Stamp", DateTime.Now); .Add("Cust omAttribut e", "CustomAttributeValue");
myTable.ExtendedProperties
myTable.ExtendedProperties
hope it works