1

How do i get the value in this chunk of html code

<select id="convert-from" name="currency-1">
  <option value='EUR'>Euro (EUR)</option>
  <option value='GBP'>British Pound (GBP)</option>
  <option value='USD'>United States Dollar (USD)</option>
  <option value='AUD'>Australian Dollar (AUD)</option>
  <option value='CAD'>Canadian Dollar (CAD)</option>
  <option value='CHF'>Swiss Franc (CHF)</option>
  <option value='CNY'>Chinese Yuan (CNY)</option>
</select>

I want the value e.g EURO (EUR), Brish Pound (GBP) and output it into a file called currency.txt in this format:

EURO (EUR)
British Pound (GBP)
United States Dollar (USD)
Australian Dollar (AUD)

GSerg
  • 76,472
  • 17
  • 159
  • 346
user1548465
  • 65
  • 1
  • 6
  • 2
    Just google for `C++ HTML parser` and you will get lots of useful results. Also have a look at [this other question](http://stackoverflow.com/questions/489522/library-recommendation-c-html-parser). – betabandido Jul 25 '12 at 09:01
  • If its for a one of, a simple sed/awk script will do. If you'll have to do it regularly, then use and XML/HTML parser – gastush Jul 25 '12 at 09:03
  • I will use libxml to parse it – Deqing Jul 26 '12 at 01:13

1 Answers1

3

Use an XML/HTML parser (I'm not going to recommend any specific ones, but there are plenty). A less general approach would be to try to parse this yourself, e.g. using regular expressions.

Oleg2718281828
  • 1,039
  • 7
  • 17
  • You haven't been around too long, so you're forgiven for suggesting to 'parse' HTML using regular expression despite of the answer given about this at http://stackoverflow.com/a/1732454/91757 ;-) – Frerich Raabe Jul 25 '12 at 09:04
  • @FrerichRaabe I didn't suggest parsing general HTML using regular expressions, just the pseudo-format that the OP presented. I pointed this out ("less general" *vide supra*) – Oleg2718281828 Jul 25 '12 at 09:06