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. Removing specific node in XML .
Forum Updated to NodeBB v4.3 + New Features

Removing specific node in XML .

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.9k Views 1 Watching
  • 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.
  • B Offline
    B Offline
    BibekKumar
    wrote on last edited by
    #1

    I have created XML file using QXmlStreamWriter .

    How can i delete one MaterialDetails node based on some key value (here it is descrip)

    @<?xml version="1.0" standalone="yes"?>
    <MaterialDetails Descrip="Material-2">
    <Ref> 70 </Ref>
    <Min> 70 </Min>
    <Max> 70 </Max>
    <ColdTrans> 70 </ColdTrans>
    <HotTrans> 70 </HotTrans>
    <ParameterVal> 11 5 1.03e+07</ParameterVal>
    </MaterialDetails>

    <MaterialDetails Descrip="Material-1">
    <Ref> 70 </Ref>
    <Min> 70 </Min>
    <Max> 70 </Max>
    <ColdTrans> 70 </ColdTrans>
    <HotTrans> 70 </HotTrans>
    <ParameterVal> 11 5 1.05e+07 </ParameterVal>
    </MaterialDetails>@

    1 Reply Last reply
    0
    • A Offline
      A Offline
      adam.bogocz
      wrote on last edited by
      #2

      Hi,
      one option is to use XPath as filter, so you will filter out stuff you DONT WANT and store the result.

      1 Reply Last reply
      0
      • B Offline
        B Offline
        BibekKumar
        wrote on last edited by
        #3

        Thanks for giving reply .
        I have given Desc attribute which can be used as a id . Instead of writing everything again , is there any concept like it will search the tag based on desc attribute , if it finds its value as Material-2 then it will delete the MaterialDetails node .

        1 Reply Last reply
        0
        • A Offline
          A Offline
          adam.bogocz
          wrote on last edited by
          #4

          Hi,
          there is nothing you need to implement, Qt supports XPath,XQuery.. e.g. to delete wanted node just use( your example was missing root node, so I have added node xml

          /xml/MaterialDetails[@Descrip!='Material-2']

          see http://www.w3schools.com/xquery/xquery_example.asp

          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