Guest User

Untitled

a guest
Apr 9th, 2019
233
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. QByteArray byteArray = reply->readAll();
  2. QString content = QString::fromUtf8(byteArray);
  3. int startPos = content.indexOf("<table class=MsoNormalTable");
  4. int endPos = content.indexOf("</table>", startPos);
  5. QStringRef html(&content, startPos, endPos - startPos + 8);
  6. QString xmlString = "<?xml version=\"1.0\"?>" + html.toString();
  7. xmlString = xmlString.replace("<o:p>&nbsp;</o:p>", "");
  8. xmlString = xmlString.replace("<o:p></o:p>", "");
  9. xmlString = xmlString.replace("&nbsp;", "");
  10. xmlString = xmlString.replace(" class=MsoNormalTable border=1 cellspacing=1 cellpadding=0", "");
  11. xmlString = xmlString.replace(" lang=EN-US", "");
  12. xmlString = xmlString.replace("<p class=MsoNormal align=center style='text-align:center'>", "");
  13. xmlString = xmlString.replace("<p class=MsoNormal>", "");
  14. xmlString = xmlString.replace("</p>", "");
  15. xmlString = xmlString.replace("<b>", "");
  16. xmlString = xmlString.replace("</b>", "");
  17. xmlString = xmlString.replace("\n", "");
  18. QXmlStreamReader xmlStreamReader(xmlString);
  19. QString natBankRate = "";
  20. while (!xmlStreamReader.atEnd())
  21. {
  22.     QXmlStreamReader::TokenType tokenType = xmlStreamReader.readNext();
  23.     if (tokenType == QXmlStreamReader::StartElement && xmlStreamReader.name() == "tr" && xmlStreamReader.attributes()[0].value() == "mso-yfti-irow:2")
  24.     {
  25.         xmlStreamReader.readNextStartElement(); //td
  26.         xmlStreamReader.readNextStartElement(); //span
  27.         xmlStreamReader.readNextStartElement(); // a
  28.         xmlStreamReader.readNextStartElement(); // a
  29.         xmlStreamReader.readNextStartElement(); // span
  30.         xmlStreamReader.readNextStartElement(); // td
  31.         xmlStreamReader.readNextStartElement(); // td
  32.         xmlStreamReader.readNextStartElement(); // span #1 (start)
  33.         xmlStreamReader.readNext();
  34.         natBankRate += xmlStreamReader.text();
  35.         xmlStreamReader.readNextStartElement(); // span #1 (end)
  36.         xmlStreamReader.readNextStartElement(); // span #2 (start)
  37.         xmlStreamReader.readNext();
  38.         natBankRate += xmlStreamReader.text();
  39.         xmlStreamReader.readNextStartElement(); // span #2 (end)
  40.         xmlStreamReader.readNextStartElement(); // span #3 (start)
  41.         xmlStreamReader.readNext();
  42.         natBankRate += xmlStreamReader.text();
  43.         ui->le_natBankRate->setText(natBankRate);
  44.         break;
  45.     }
  46. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×