SHARE
TWEET

Untitled

a guest Apr 9th, 2019 183 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
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top