Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

An interview Question about XML

 
Sam Sunamin
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

Recently, I got an interview about xml. I am not so sure about XML since I never used it to represent data.

How to use xml to represent several the same data just like the loop in Java?

It is possible? I check the xml's syntax, and I think it is impossible. It all depends on the client who uses XML data.

Am I right?

Please give me an answer.

Thank you in advance.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to use xml to represent several the same data just like the loop in Java?


That statement seems to mix up data representation with program structure

If you mean can XML represent repeating elements such as an array then the answer is yes.

Bill
[ November 15, 2007: Message edited by: William Brogden ]
 
Sam Sunamin
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you mean can XML represent repeating elements such as an array then the answer is yes.

How do you do this? I tried to find from w3c but I cannot find it.

Thank you in advance.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose we are going to represent an array of integers:

<values>
<val n="0">100</val>
<val n="1">220</val>
<val n="2">456</val>
</values>

Here the <values> element contains repeating elements - each one has an attribute giving an index (not really necessary, just to demo) and a text node content string value.

Don't get discouraged, it takes a while to get your head wrapped around the possibilities of XML.

Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic