开发者

Ways of Linking/Referencing XML nodes

开发者 https://www.devze.com 2023-01-07 15:28 出处:网络
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

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>
  <hai开发者_运维技巧rcolor>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?


I think you are looking for something like Cross Referencing Your XML Data.

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>
0

精彩评论

暂无评论...
验证码 换一张
取 消