Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. XML- Explanation
QtWS25 Last Chance

XML- Explanation

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 1.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Paawan
    wrote on last edited by
    #1

    Good Day,

    I want to understand the following methods in XML handlers:

    startDocument(): How does this method work? Does it look for the first "<" element or any text?

    endDocument(): How does it know the document has ended?

    startElement(): Again how does it know the element has started

    endElement(): How does it know it is the end element?

    Thanks

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      Hi,

      I haven't used the handlers you posted, but here is what I know about QXmlStreamReader. I believe the detection mechanism is similar:

      All tokens are detected when the '>' character is found.

      • StartDocument is detected at the '>' of the XML declaraion.
      • StartElement is detected at the '>' of an element start tag.
      • EndElement is detected at the '>' of an element end tag.
      • EndDocument is detected at the '>' of the end tag of your top-level element.

      Using the following document as an example:
      @
      <?xml version="1.0" encoding="UTF-8"?>
      <Reply category="INIT">
      <InitClusters>
      <Cluster id="A" x="0" y="0"/>
      <Cluster id="B" x="2" y="2"/>
      </InitClusters>
      </Reply>
      @

      • <?xml version="1.0" encoding="UTF-8"?> -- StartDocument
      • <Reply category="INIT"> -- StartElement
      • <InitClusters> -- StartElement
      • <Cluster id="A" x="0" y="0"/> -- StartElement and EndElement
      • <Cluster id="B" x="2" y="2"/> -- StartElement and EndElement
      • </InitClusters> -- EndElement
      • </Reply> -- EndElement and EndDocument

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • P Offline
        P Offline
        Paawan
        wrote on last edited by
        #3

        Thanks for the reply.

        Can we say that <something> is a start element ?

        and

        </something> is an end element?

        Is my understanding correct?

        The reader/handler knows it has reached the end of the document because it has previous read <Reply category="INIT"> and then it has found the </Reply> element.

        Is my understanding correct?

        Thank you for the help.

        1 Reply Last reply
        0
        • JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #4

          You're welcome.

          [quote author="Paawan" date="1410075609"]Can we say that <something> is a start element ?

          and

          </something> is an end element?

          Is my understanding correct?[/quote]Correct.

          Also, <something/> is a small element that starts and ends at the same time.

          [quote author="Paawan" date="1410075609"]The reader/handler knows it has reached the end of the document because it has previous read <Reply category="INIT"> and then it has found the </Reply> element.

          Is my understanding correct?[/quote]Correct.

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          1 Reply Last reply
          0
          • P Offline
            P Offline
            Paawan
            wrote on last edited by
            #5

            Thank you very much again.

            1 Reply Last reply
            0
            • P Offline
              P Offline
              Paawan
              wrote on last edited by
              #6

              There has been a sample XML file that was given with the book.

              @
              <section id="xmlintro">
              <title> Intro to XML </title>
              <p> This is a paragraph </p>
              <ul>
              <li> This is an unordered list item. </li>
              <li c="textbook"> This only shows up in the textbook </li>
              </ul>

              <p> The code example below shows how
                   slacker processes includes: </p>
              <include src="testhello.cpp" mode="cpp"/>
              

              <p> And here is another paragraph </p>
              </section>

              @

              In this file the xml version part is not given. How will the reader know that document is starting? By this I mean where is the StartDocument part in this file?

              Thanks

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved