SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jun 2000
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Line breaks for nested elements?

    Just curious, in all examples (i.e. in tutorials, books, etc.) I see child/sub-elements on a NEW line from the main element, for example:
    <note>
    <title>foo</title>
    <message>bar</message>
    </note>
    I've never seen:
    <note><title>foo</title>
    <message>bar</message></note>

    What I'd like to know is: is this a REQUIREMENT of XML, that each element be on its own line, or is this just a style nicety that most people obey?

  2. #2
    morphine for a wooden leg randem's Avatar
    Join Date
    Jun 2002
    Location
    .chicago.il.us
    Posts
    957
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's not a requirement. In fact, whitespace means nothing to XML. This is something that people do to make their code easier to read.

  3. #3
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Exactly - "<note><title>foo</title><message>bar</message></note>" would be fine too!


    M@rco
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!

  4. #4
    SitePoint Member
    Join Date
    Jun 2000
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So, to write a parser that processes everything 100% correctly, the value of <note> in my example would have to be a bunch of line breaks, in addition to its sub-elements?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •