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. A little help here with QtNetwork
Forum Updated to NodeBB v4.3 + New Features

A little help here with QtNetwork

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

    I'm writing a program that customers get tax information from a web portal., I give them a part of my code:

    @void RIF::replyFinished(QNetworkReply *reply)
    {
    QByteArray data = reply->readAll();
    QString str(data);
    qDebug() << str;
    ui->textEdit->setText(str);
    }

    void RIF::on_queryButton_clicked()
    {
    QNetworkAccessManager manager = new QNetworkAccessManager(this);
    connect(manager, SIGNAL(finished(QNetworkReply
    )),
    this, SLOT(replyFinished(QNetworkReply*)));

    manager->get(QNetworkRequest(QUrl("http://somepage.com/getrif?rif=" + RIF::_rif())));
    

    }@

    which I get the following information:

    @"<?xml version="1.0" encoding="ISO-8859-1"?>
    <rif:Rif xmlns:rif="rif" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" rif:numeroRif="V1X5XX60XX">rif:NombreCUSTOMER NAME</rif:Nombre>rif:AgenteRetencionIVANO</rif:AgenteRetencionIVA>rif:ContribuyenteIVASI</rif:ContribuyenteIVA>rif:Tasa75</rif:Tasa></rif:Rif>
    "@

    This XML string only has two lines

    How I can access a particular record, for example, rif:Nombre (this is the legal name of the client) or any records started like (rif:)?

    Thanking your support and attention

    Sorry for my bad english, I translate this with google translator :)

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You can use Qt's XML/ XML patterns modules to parse your data.

      Be aware that you have a problem with your code here. Each time you call on_queryButton_clicked you create a new QNAM which is not needed. Just create it once as a member variable and re-use it to make your queries.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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