is this good practice ?

G

Gieke

hi group,
I'm new here. Worked a bit with xml over the years, and now having a
discussion if something is allowed or not, or good practice or not.
It's about repeating a tag within a tag that contains also other things.
an example to make it clear:

<basicFlightInfo>
<flightDetails>
<departureDate>011008</departureDate>
<departureTime>0834</departureTime>
</flightDetails>
<departureLocation>
<cityAirport>ZWE</cityAirport>
</departureLocation>
<productTypeDetail>D</productTypeDetail>
<productTypeDetail>702</productTypeDetail>
<productTypeDetail>ET</productTypeDetail>
</basicFlightInfo>

Is it allowed to repeat the <productTypeDetail> ?
Would it be better to nest it in another tag, like :
<details>
<productTypeDetail>D</productTypeDetail>
<productTypeDetail>702</productTypeDetail>
<productTypeDetail>ET</productTypeDetail>
</details>

Or is it necessary to do so ?

thanks for advice !

Guido
 
P

Pavel Lepin

Gieke said:
It's about repeating a tag within a tag that contains also
other things. an example to make it clear:

<basicFlightInfo>
<flightDetails>
<departureDate>011008</departureDate>
<departureTime>0834</departureTime>
</flightDetails>
<departureLocation>
<cityAirport>ZWE</cityAirport>
</departureLocation>
<productTypeDetail>D</productTypeDetail>
<productTypeDetail>702</productTypeDetail>
<productTypeDetail>ET</productTypeDetail>
</basicFlightInfo>

Is it allowed to repeat the <productTypeDetail> ?

It is definitely allowed.
Would it be better to nest it in another tag, like :
<details>
<productTypeDetail>D</productTypeDetail>
<productTypeDetail>702</productTypeDetail>
<productTypeDetail>ET</productTypeDetail>
</details>

Or is it necessary to do so ?

This is by no means necessary, but a good practice in my
opinion. Well-structured documents are much easier to
process.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top