Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Starting XML question....

Status
Not open for further replies.

ChrisC456

Programmer
Mar 26, 2006
1
GB
Hi,

I'm very new to XML and I'm used to OOP, so i've got a question related to these two...

Say I was writing an XML document, and I have information on Authors and Articles:

<author>
<name>Alex Jones</name>
etc
</author>

<article>
<title>XML</title>
<category>Computers</category>
</article>

If an author can write many articles, and an article is only written by one author, would I need to put something inside <article></article> in order to link it to the right author?
Or is this done somewhere else?

Thanks.
 
XML is not a programming language, it is simply a structured data store. Both the structure and the data are entirely up to you (unless you're working from a schema).

It would be logical for the articles to appear under the author node, eg:
Code:
<author>
  <name>Alex Jones</name>
  <article>
    <title>XML</title>
    <category>Computers</category>
  </article>
  <article>
    <title>C#</title>
    <category>Computers</category>
  </article>
</author>
You'd probably want a list of authors:
Code:
<authors>
  <author>
  ....
  </author>
  <author>
  ....
  </author>
  ....
</authors>

Jon

"I don't regret this, but I both rue and lament it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top