0

I have been struggling with extracting data from CDATA part of an XML using R. Here is the part of the file that I have been working on.

<DOCUMENT_INFO>
<TEXT><![CDATA[




Management’s Discussion and Analysis  
Third quarter ended September 30, 2013    

This Management?s Discussion and Analysis (“MD&A”) should be read in conjunction with the  condensed interim  consolidated 
financial statements of First Quantum Minerals Ltd. (“First Quantum” or “the Company”) for the three months (“the quarter”) and 
nine  months  ended  September  30,  2013.  The  Company?s  results  have  been  prepared  in  accordance  with  International  Financial 
Reporting  Standards  (“IFRS”)  and  are  presented  in  United  States  dollars (“USD”),  tabular  amounts  in  millions,  except  where 
noted. Changes in accounting policies have been applied consistently to comparative periods unless otherwise noted. 

For  further  information  on  First  Quantum,  reference  should  be  made  to  its  public  filings  (including  its  most  recently  filed  AIF) 
which  are  available  on  SEDAR  at  www.sedar.com. Information  is  also  available  on  the  Company?s  website  at www.first-
quantum.com. This MD&A contains forward-looking information that is subject to risk factors, see “Regulatory Disclosures” for 
further  discussion. Information  on  risks  associated  with  investing  in  the  Company?s  securities  and  technical  and  scientific 
information under National Instrument 43-101 concerning the Company?s material properties, including information about mineral 
resources and reserves, are contained in its most recently filed AIF. This MD&A has been prepared as of October 30, 2013. 
SUMMARIZED OPERATING AND FINANCIAL RESULTS
1


Three months ended  
September 30 
Nine months ended  
September 30 
(USD millions unless otherwise noted) 
2013                 2012                 2013                 2012 
Copper production (tonnes)                                                                        114,488              84,144            297,490            222,198 
Copper sales (tonnes)                                                                                 105,859              77,396            290,459            217,896 
Cash cost of copper production (C1)
2
 (per lb)                                               $1.16                $1.44                $1.33                $1.51 
Realized copper price (per lb)                                                                      $3.10                $3.45                $3.22                $3.53 
Nickel production (contained tonnes)                                                          12,485                9,916              34,432              26,663 
Nickel sales (contained tonnes)                                                                    12,335                7,120              35,310              22,298 

I would like to extract Copper production, copper sales etc. out of this file by using XML package of R.

Chrisxx
  • 7
  • 3
  • "struggling" implies code attempts. where are said code attempts? the xml snippet is also incomplete (thus invalid) xml. – hrbrmstr Mar 13 '17 at 07:39
  • Have you tried using the `XML` package? Try to parse the complete XML file with `xmlParse()` and turn that object into a list with `xmlToList()`. This question might help you: http://stackoverflow.com/questions/17198658/how-to-parse-xml-to-r-data-frame – ottlngr Mar 13 '17 at 08:59
  • The fact that the text is in a CDATA section of an XML document is surely irrelevant? Getting the content of the CDATA section as text is trivial, after that there's no markup, so you're outside the domain where XML markup or XML tools and techniques can help you. – Michael Kay Mar 13 '17 at 10:23
  • @hrbrmstr Of course! I just did not want to add it as it is a document that I should not share. – Chrisxx Mar 13 '17 at 20:08
  • @MichaelKay I agree with you! – Chrisxx Mar 13 '17 at 20:09
  • In which case, tagging it with keywords (and titling it) to bring it to the attention of XML folks is unproductive. – Michael Kay Mar 14 '17 at 09:08
  • @MichaelKay Thx bro, worked – Chrisxx Mar 17 '17 at 20:04

0 Answers0