Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes XML and Related Technologies and the fly likes An interview Question about XML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "An interview Question about XML" Watch "An interview Question about XML" New topic
Author

An interview Question about XML

Sam Sunamin
Ranch Hand

Joined: Mar 16, 2007
Posts: 113
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.


Yours Sam<br />SCJP5.0 97%<br />SCBCD5.0 72%
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12787
    
    5
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

Joined: Mar 16, 2007
Posts: 113
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

Joined: Mar 22, 2000
Posts: 12787
    
    5
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: An interview Question about XML