Description Usage Arguments Examples
View source: R/xml_to_dataframe.R
xml_to_dataframe() convert xml_nodeset object to data.frame.
1 | xml_to_dataframe(nodeset)
|
nodeset |
a dataframe. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | xml <- "<?xml version='1.0' encoding='UTF-8'?>
<response>
<header>
<resultMsg>NORMAL SERVICE</resultMsg>
</header>
<body>
<items>
<item>
<num>1</num>
<date>20160413</date>
<title>test_title1</title>
<code>0</code>
<time>08:23</time>
</item>
<item>
<num>2</num>
<date>20160414</date>
<title>test_title2</title>
<code>2</code>
<time>22:23</time>
</item>
<item>
<num>3</num>
<date>20200415</date>
<title>test_title3</title>
<code>7</code>
<time>20:47</time>
</item>
</items>
<numOfRows>3</numOfRows>
<pageNo>1</pageNo>
<totalCount>3</totalCount>
</body>
</response>"
doc <- xml2::read_xml(xml)
items <- xml2::xml_find_all(doc, '//item')
df <- xml_to_dataframe(items)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.