Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to parse/write the attributes of a tag using QDomNode?
Forum Updated to NodeBB v4.3 + New Features

How to parse/write the attributes of a tag using QDomNode?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
4 Posts 2 Posters 981 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.
  • K Offline
    K Offline
    kishore_hemmady
    wrote on last edited by
    #1

    This is my XML
    <FileName>
    <File Width="" Name="../SupportFiles/TestVectors/10b- Cityscape [Landscape] 1 Min_1080p MP4.mp4" Height="" Format="" FrameRate=""/>
    </FileName>

    I should read only Name attribute of the FileName tag.How do I do this using QDom?How to write attributes using QDom?

    JonBJ 1 Reply Last reply
    0
    • K kishore_hemmady

      This is my XML
      <FileName>
      <File Width="" Name="../SupportFiles/TestVectors/10b- Cityscape [Landscape] 1 Min_1080p MP4.mp4" Height="" Format="" FrameRate=""/>
      </FileName>

      I should read only Name attribute of the FileName tag.How do I do this using QDom?How to write attributes using QDom?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @kishore_hemmady
      doc.qt.io/qt-5/qdomattr.html contains all the details, including examples of reading & writing.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kishore_hemmady
        wrote on last edited by
        #3

        hi @JonB
        how can i Write the above xml using XMLStreamWritter class.

        JonBJ 1 Reply Last reply
        0
        • K kishore_hemmady

          hi @JonB
          how can i Write the above xml using XMLStreamWritter class.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @kishore_hemmady
          For writing an attribute, if that's what you mean:

          QXmlStreamWriter w = // ...
          QDomElement e = //...
          //...
          QDomAttr a = e.attributeNode("Name");
          // ...
          w.writeAttribute(e.name(), e.value());
          

          But now you're asking about QXmlStreamWriter, which you weren't before. I don't know why you're mixing this with QDom. Normally, you read everything with QDom, maybe make some changes, and then write everything back with QDom. Take a look at e.g. http://www.informit.com/articles/article.aspx?p=1405553&seqNum=4:

          Using QXmlStreamWriter to write XML is the easiest and safest approach, but if we already have the XML in a DOM tree, we can simply ask the tree to output the relevant XML by calling save() on the QDomDocument object.

          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