views:

17

answers:

1

Alright this question might sound a little bit stupid but I don't know where to start so I'll simply ask:

I need a way to link or reference XML nodes among each other. So I started interviewing google and did find a few examples...yet I am not quite satisfied with the solutions i found. So i was wondering if there is a commonly accepted way to link XML Elements among one another?

Lets say I have this XML file:

<person>
  <name>Martin</name>
  <age>16</age>
  <haircolor>blond</haircolor>
</person>

<dog>
  <name>Muttley</name>
  <age>5</age>
</dog>

Now a need a way to express that Martin is the lordling of Muttley or that Muttley is the Dog of Martin.

I was thinking about some kind of reference or pointer within the XML file that points to the right node?

I guess there are a few ways to achieve that goal but what is the best one?

Thanks....

+1  A: 

I think you are looking for something like this - Cross Referencing Your XML Data http://msdn.microsoft.com/en-us/library/ms950811.aspx.

Uses Id and Ref attributes in your XML

So, in your example...

<person id="x">
  <name>Martin</name>
  <age>16</age>
  <haircolor>blond</haircolor>
</person>

<dog>
  <name>Muttley</name>
  <age>5</age>
  <lordling ref="x"/>
</dog>
barrylloyd