What is it that distinguishes the <state...> and <city...> tags from the <country...> tags? Is it strictly that the OP's code provides the shortcut close, "/>" for state and city but not for country? If <country...> had a shortcut close would it not need a </county> tag? And if so, why not use a shortcut close globally -- that is, on <world> and <country>. I still don't "get it" in that regard.

It seems to me that consistency would make parsing easier... and might even help explain why the OP (you?) is seeing unexpected numbers of elements.

I'm quite curious, because a simpleminded search on "XML close tag" produced a selection of inconsistent assertions.

On the first paw, your explanation doesn't seem consistent with beginner tuts like that at http://www.w3schools.com/xml/xml_syntax.asp nor with http://www.w3schools.com/xml/xml_dtd.asp nor http://www.xmlfiles.com/xml/xml_syntax.asp -- none of which are authoratative (but I'm too full of turkey to chase it down -- and while you may suspect a turkey byproduct, that's another discussion). All of those agree that the only or chief exception to a "must have a closing tag" rule is the <empty-element />

But on the hind paw, the XML validator at http://www.w3schools.com/xml/xml_validator.asp passes, as "well formed," the OP's code, when that is modified with a leading <?xml version...> header, and has the elipsis replaced with arbitary sample data.

Thus, while I'm still uncertain "why" and "how" your take on the matter can be true, I won't dispute it (at least for the moment).

I will, however, quibble with your assertions about html. They're good examples of the point you're making... but they're NOT entirely correct. The standards for 4.01 transitional and 4.01 strict differ on what's required, where. Your link example is correct ("valid") in both; the shortcut close on image is NOT required by 4.01 transitional (aka "loose"). And html5 is a fish with different feathers.

In any case,, if you posted the OP as an AM and are now expanding on that post, please provide the sample output requested above... and, whether you are the OP or not, thank you for taking the time and effort to reply.


In reply to Re^3: XML::LibXML::Reader giving wrong matched element by ww
in thread XML::LibXML::Reader giving wrong matched element by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.