Well-formed XML question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Paul Flew

    #1

    Well-formed XML question

    Hi

    I'm sure this is a very simple question, but can someone tell me whether the
    following is a well-formed XML document (not withstanding the lack of DTD):

    <document>Som e text <documentcompon ent>Component Part</documentcompone nt>
    some more text </document>

    i.e. Embedding a tag within the contents of another tag (a la HTML)?

    I'm writing a piece of software which takes a text document and returns
    those words within it which it identifies as particular components (date,
    etc), for which obviously the above format is potentially most suitable.

    Any help appreciated, even if its just pointing at a relevant FAQ.

    Regards,



    Paul

    ps. Remove the .nospam to respond directly.


  • Johannes Koch

    #2
    Re: Well-formed XML question

    Paul Flew wrote:[color=blue]
    > Hi
    >
    > I'm sure this is a very simple question, but can someone tell me whether the
    > following is a well-formed XML document (not withstanding the lack of DTD):
    >
    > <document>Som e text <documentcompon ent>Component Part</documentcompone nt>
    > some more text </document>[/color]

    It is.
    --
    Johannes Koch
    In te domine speravi; non confundar in aeternum.
    (Te Deum, 4th cent.)

    Comment

    • Tad McClellan

      #3
      Re: Well-formed XML question

      Paul Flew <paul.flew@opti madm.nospam.com > wrote:
      [color=blue]
      > I'm sure this is a very simple question, but can someone tell me whether the
      > following is a well-formed XML document (not withstanding the lack of DTD):
      >
      ><document>So me text <documentcompon ent>Component Part</documentcompone nt>
      > some more text </document>[/color]


      Yes, it is well-formed.

      Why ask thousands of people around the world to spend grey-matter
      cycles on a question easily answered with silicon-cycles?

      ie. Why not run the document through an XML parser, and see what happens?

      [color=blue]
      > i.e. Embedding a tag within the contents of another tag (a la HTML)?[/color]


      That is *not* embedding a tag within a tag.

      Embedding a tag within a tag is not allowed in XML.

      Embedding an element within an element is allowed though.

      See the XML FAQ:




      --
      Tad McClellan SGML consulting
      tadmc@augustmai l.com Perl programming
      Fort Worth, Texas

      Comment

      • Micah Cowan

        #4
        Re: Well-formed XML question

        "Paul Flew" <paul.flew@opti madm.nospam.com > writes:
        [color=blue]
        > Hi
        >
        > I'm sure this is a very simple question, but can someone tell me whether the
        > following is a well-formed XML document (not withstanding the lack of DTD):[/color]

        The lack of DTD doesn't affect its well-formedness, only its "validity".
        [color=blue]
        > <document>Som e text <documentcompon ent>Component Part</documentcompone nt>
        > some more text </document>
        >
        > i.e. Embedding a tag within the contents of another tag (a la HTML)?[/color]

        This doesn't affect the well-formedness or validity of an XML document
        (didn't you know that HTML has an extremely similar XML counterpart,
        XHTML?)

        -Micah

        Comment

        Working...