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. Parsing XML stop on Item inside Item
Forum Updated to NodeBB v4.3 + New Features

Parsing XML stop on Item inside Item

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 197 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.
  • F Offline
    F Offline
    filipdns
    wrote on last edited by
    #1

    Hello,

    I'm trying to parse XML but in the line I need to read as text I have :

    //<HotLink targetrefid="../xml/37-00-00-001.xml" type="intraM" wp:type="container">Chapter 37-00-00, 001</HotLink>
    

    then the string stop before it.

    How can I have result like:

    Vacuum pressure for the pressure controller is controlled by the vacuum regulator that also regulates instrument vacuum. The regulator is located immediately forward of the forward pressure bulkhead. Refer to Chapter 37-00-00, 001 for further information on the vacuum regulator.

    here the XML interested line

    <Para NCW_TextAlign="Left" wp:type="para">
    Vacuum pressure for the pressure controller is controlled by the vacuum regulator that also regulates instrument vacuum. The regulator is located immediately forward of the forward pressure bulkhead. Refer to <HotLink targetrefid="../xml/37-00-00-001.xml" type="intraM" wp:type="container">Chapter 37-00-00, 001</HotLink> for further information on the vacuum regulator.
    </Para>
    

    here my part of code:

        QFile file("C:/XML/21-30-00-001.xml");
        if(!file.open(QFile::ReadOnly | QFile::Text)){
            qDebug() << "Cannot read file" << file.errorString();
            exit(0);
        }
        QXmlStreamReader xml(&file);
        QString Para;
        QString HotLink;
    
        while (!xml.atEnd())
        {xml.readNext();
    
            if (xml.isStartElement())
            {
                QString name = xml.name().toString();
                if (name == "Para")
                {
    
                    Para=xml.readElementText();
                }
    
                qDebug() << Para;
    
            }
    
        }
    

    and the string result on console:

    "\nVacuum pressure for the pressure controller is controlled by the vacuum regulator that also regulates instrument vacuum. The regulator is located immediately forward of the forward pressure bulkhead. Refer to "
    

    thank you very much for your help

    1 Reply Last reply
    0
    • F Offline
      F Offline
      filipdns
      wrote on last edited by
      #2

      Solved with

      Para=xml.readElementText(QXmlStreamReader::IncludeChildElements);
      
      1 Reply Last reply
      1

      • Login

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