# XML Question

**URL:** <https://boards.straightdope.com/t/xml-question/402646>\
**Category:** Factual Questions\
**Created:** [May 3, 2007, 7:04pm UTC](https://boards.straightdope.com/t/xml-question/402646 "2007-05-03T19:04:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fiddle\_Peghead](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/fiddle_peghead/32/3506_2.png) [@Fiddle\_Peghead](https://boards.straightdope.com/u/Fiddle_Peghead)\
**Post date:** [May 3, 2007, 7:04pm UTC](https://boards.straightdope.com/t/xml-question/402646/1 "2007-05-03T19:04:00Z")

</div>

Should I be able to do this in an XML schema?

\<POT\_EXAM\_SCORE\>  
\<POT\_EXAM\_SCORE\>1234\</POT\_EXAM\_SCORE\>  
\</POT\_EXAM\_SCORE\>

As written, I do not get any data for POT\_EXAM\_SCORE, and do only if I give the lower level element a unique name. Can this be made to work as written?

---

<div class="post-metadata">

**Author:** ![toadspittle](https://avatars.discourse-cdn.com/v4/letter/t/c0e974/32.png) [@toadspittle](https://boards.straightdope.com/u/toadspittle)\
**Post date:** [May 3, 2007, 7:16pm UTC](https://boards.straightdope.com/t/xml-question/402646/2 "2007-05-03T19:16:35Z")

</div>

[QUOTE=Fiddle Peghead]  
Should I be able to do this in an XML schema?

\<POT\_EXAM\_SCORE\>  
\<POT\_EXAM\_SCORE\>1234\</POT\_EXAM\_SCORE\>  
\</POT\_EXAM\_SCORE\>

As written, I do not get any data for POT\_EXAM\_SCORE, and do only if I give the lower level element a unique name. Can this be made to work as written?  
[/QUOTE]

Why are you nesting identical elements?

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [May 3, 2007, 7:16pm UTC](https://boards.straightdope.com/t/xml-question/402646/3 "2007-05-03T19:16:35Z")

</div>

You can do it if you’re willing to write your own XML parser, but it sure seems like it’d be a lot simpler to just give the outer tag a different name (POT\_EXAM\_SCORES, perhaps?).

---

<div class="post-metadata">

**Author:** ![Fiddle\_Peghead](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/fiddle_peghead/32/3506_2.png) [@Fiddle\_Peghead](https://boards.straightdope.com/u/Fiddle_Peghead)\
**Post date:** [May 3, 2007, 7:22pm UTC](https://boards.straightdope.com/t/xml-question/402646/4 "2007-05-03T19:22:40Z")

</div>

I’m not writing them, I’m only using them. I’m new to XML and want to look like I know what I’m talking about when I speak with those who will have to make changes.

Thanks.

---

<div class="post-metadata">

**Author:** ![LilShieste](https://avatars.discourse-cdn.com/v4/letter/l/9f8e36/32.png) [@LilShieste](https://boards.straightdope.com/u/LilShieste)\
**Post date:** [May 3, 2007, 8:52pm UTC](https://boards.straightdope.com/t/xml-question/402646/5 "2007-05-03T20:52:14Z")

</div>

[QUOTE=Fiddle Peghead]  
Should I be able to do this in an XML schema?

\<POT\_EXAM\_SCORE\>  
\<POT\_EXAM\_SCORE\>1234\</POT\_EXAM\_SCORE\>  
\</POT\_EXAM\_SCORE\>

As written, I do not get any data for POT\_EXAM\_SCORE, and do only if I give the lower level element a unique name. Can this be made to work as written?  
[/QUOTE]

How are you parsing this XML data? That is, when you say, “I do not get any data for…”, how are you “getting” the data? Is there a custom application stepping through it? Are you feeding it into an XSL stylesheet?

I don’t recall anything in the XML spec that prohibits people from nesting elements with identical names. That being said, I can’t think of a single reason why anyone would want to do that, anyway - it only clouds up the schema (as **toadspittle** and **ultrafilter** had mentioned).  
LilShieste
