Click here to Skip to main content
15,893,594 members
Home / Discussions / XML / XSL
   

XML / XSL

 
QuestionUse a database or XML? Pin
dreamaway82023-May-08 5:01
dreamaway82023-May-08 5:01 
AnswerRe: Use a database or XML? Pin
led mike23-May-08 8:19
led mike23-May-08 8:19 
AnswerRe: Use a database or XML? Pin
Scott Dorman26-May-08 5:03
professionalScott Dorman26-May-08 5:03 
AnswerRe: Use a database or XML? Pin
PIEBALDconsult6-Jun-08 10:34
mvePIEBALDconsult6-Jun-08 10:34 
QuestionHow to Save full path of file in XML file like C:\xyz\patient.bmp Pin
Abhijit D. Babar22-May-08 22:28
Abhijit D. Babar22-May-08 22:28 
AnswerRe: How to Save full path of file in XML file like C:\xyz\patient.bmp Pin
led mike23-May-08 5:13
led mike23-May-08 5:13 
AnswerRe: How to Save full path of file in XML file like C:\xyz\patient.bmp Pin
PIEBALDconsult6-Jun-08 10:35
mvePIEBALDconsult6-Jun-08 10:35 
QuestionMany-To-Many DataSet as XML document Pin
Miszou22-May-08 11:07
Miszou22-May-08 11:07 
Let's say I have 3 tables which are Users, Groups and UserGroup, where a user can be a member of multiple groups and a group can obviously contain multiple users. The UserGroup table is simply a 2 column table that maintains the many-to-many relationship within the database, and this all works perfectly.
---------               -------------              ---------- 
| Users |  1 ----- many | UserGroup | many ----- 1 | Groups |
---------               -------------              ---------- 

When I attempt to load these three tables into an XML document (via a dataset) it fails with an error saying "A child row has multiple parents" - presumably because the link table (UserGroup) contains duplicate UserID's and GroupID's (Which it should!). I've tried adding an artificial primary key to the UserGroup table, but it still doesn't work.

The current code is below, and a sample of the output that I would like is also provided. What do I need to do to get this to work correctly? I've been Googling all morning, but I can't seem to find anything with an actual answer!
// sproc returns a dataset containing three tables
SqlDataAdapter da = new SqlDataAdapter( "sproc", connection );
da.SelectCommand.CommandType = CommandType.StoredProcedure;

DataSet ds = new DataSet();
da.Fill(ds);

ds.Tables[0].TableName = "User";
ds.Tables[1].TableName = "Group";
ds.Tables[2].TableName = "UserGroup";

DataRelation ea1 = ds.Relations.Add(
	ds.Tables["User"].Columns["UserID"],
	ds.Tables["UserGroup"].Columns["UserID"],
	false);

DataRelation ea2 = ds.Relations.Add(
	ds.Tables["Group"].Columns["GroupID"],
	ds.Tables["UserGroup"].Columns["GroupID"],
	false);

ea1.Nested = true;
//ea2.Nested = true; // Do I need this?
					
XmlDataDocument doc = new XmlDataDocument(ds);

I'm looking for something like this:
<Groups>
  <Group>
    <GroupName>Astronauts</GroupName>
    <Users>
      <Name>Neil Armstrong</Name>
      <Name>Buzz Aldrin</Name>
      <Name>Yuri Gagarin</Name>
    <Users>
  </Group>
  <Group>
    <GroupName>Americans</GroupName>
    <Users>
      <Name>Neil Armstrong</Name>
      <Name>Buzz Aldrin</Name>
    </Users>
  </Group>
</Groups>

Does anyone know how to do this (or something very similar)? It would be greatly appreciated!

Thank you.


Questionwrite PMML as in XML use Vc++ Pin
Member 365375120-May-08 23:42
Member 365375120-May-08 23:42 
AnswerRe: write PMML as in XML use Vc++ Pin
led mike21-May-08 6:16
led mike21-May-08 6:16 
QuestionModify large XML files [modified] Pin
rzumbado19-May-08 12:37
rzumbado19-May-08 12:37 
AnswerRe: Modify large XML files Pin
Christian Graus19-May-08 13:17
protectorChristian Graus19-May-08 13:17 
Questionindent XML and keep cdata sections? Pin
CherezZaboro19-May-08 4:13
CherezZaboro19-May-08 4:13 
Questionxml file validation using DTD in c#.net Pin
sengottuvelud16-May-08 22:35
sengottuvelud16-May-08 22:35 
QuestionValidation of XML Xpath of validation failure? Pin
AndyCLon14-May-08 5:17
AndyCLon14-May-08 5:17 
QuestionHow to parse responce XML using java script and store the result nodes and their values in Excel sheet Pin
JayPrakash Kulkarni11-May-08 22:51
JayPrakash Kulkarni11-May-08 22:51 
AnswerRe: How to parse responce XML using java script and store the result nodes and their values in Excel sheet Pin
JayPrakash Kulkarni13-May-08 4:49
JayPrakash Kulkarni13-May-08 4:49 
AnswerRe: How to parse responce XML using java script and store the result nodes and their values in Excel sheet Pin
led mike14-May-08 4:36
led mike14-May-08 4:36 
QuestionXslt 2.0, xsl functions and Internet explorer Pin
Yariv9-May-08 6:31
Yariv9-May-08 6:31 
QuestionHow to Parse CData value through ISAXXMLReader Pin
pch19827-May-08 21:56
pch19827-May-08 21:56 
QuestionHow to Generate HTML Reports in C#.. Pin
Aswanth4-May-08 21:59
Aswanth4-May-08 21:59 
AnswerRe: How to Generate HTML Reports in C#.. Pin
led mike6-May-08 4:57
led mike6-May-08 4:57 
AnswerRe: How to Generate HTML Reports in C#.. [modified] Pin
Vinay Dornala9-May-08 0:40
Vinay Dornala9-May-08 0:40 
GeneralRe: How to Generate HTML Reports in C#.. Pin
Christian Graus11-May-08 23:19
protectorChristian Graus11-May-08 23:19 
QuestionSearching against child node in XML Pin
kmpatel4-May-08 11:26
kmpatel4-May-08 11:26 

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.