r - Cannot run xmlParse() -
i trying read xml
file using function xmlparse()
on rstudio
. have installed , loaded (globally) packages required this, namely xml
, methods
. here code:
setwd("~/desktop/r ") xmlparse(file = "input.xml")
i set directory file input.xml
located. information in file looks this:
<records> <employee> <id>1</id> <name>rick</name> <salary>623.3</salary> <startdate>1/1/2012</startdate> <dept>it</dept> </employee> <employee> <id>2</id> <name>dan</name> <salary>515.2</salary> <startdate>9/23/2013</startdate> <dept>operations</dept> </employee> <employee> <id>3</id> <name>michelle</name> <salary>611</salary> <startdate>11/15/2014</startdate> <dept>it</dept> </employee> <employee> <id>4</id> <name>ryan</name> <salary>729</salary> <startdate>5/11/2014</startdate> <dept>hr</dept> </employee> <employee> <id>5</id> <name>gary</name> <salary>843.25</salary> <startdate>3/27/2015</startdate> <dept>finance</dept> </employee> <employee> <id>6</id> <name>nina</name> <salary>578</salary> <startdate>5/21/2013</startdate> <dept>it</dept> </employee> <employee> <id>7</id> <name>simon</name> <salary>632.8</salary> <startdate>7/30/2013</startdate> <dept>operations</dept> </employee> <employee> <id>8</id> <name>guru</name> <salary>722.5</salary> <startdate>6/17/2014</startdate> <dept>finance</dept> </employee> </records>
the ouput code supposed this:
1 rick 623.3 1/1/2012 2 dan 515.2 9/23/2013 operations 3 michelle 611 11/15/2014 4 ryan 729 5/11/2014 hr 5 gary 843.25 3/27/2015 finance 6 nina 578 5/21/2013 7 simon 632.8 7/30/2013 operations howe 8 guru 722.5 6/17/2014 finance
however, getting unprocessed data (like was). don't know do.
i have tried different ways of creating xml
file. used ms word, python editor, textedit , mac notepad. pasted xml
formatted text on each of these , saved extension .xml
. don't know else do. guidance appreciated.
Comments
Post a Comment