Home  >  Article  >  Backend Development  >  XML package to import and process XML data format | R package

XML package to import and process XML data format | R package

黄舟
黄舟Original
2017-02-25 14:03:151965browse

XML package to import and process XML data format | R package

What is XML?

• XML stands for EXtensible Markup Language
• XML Is a markup language, much like HTML
• XML is designed to transmit data, not display data
• XML tags are not predefined. You need to define the labels yourself.
• XML is designed to be self-describing.
• XML is a recommended standard by W3C

For a more detailed introduction to XML, please see the link: http://www.w3school.com.cn/xml/xml_intro.asp

R How does the language parse XML?

The R language provides an XML package to parse XML data format, including importing XML data and processing XML data. Examples are as follows.

## 加载XML包
library('XML')
## 自定义一个XML数据内容
content <-   
&#39;<note>  
<name>shujuren</name>  
<url>http://shujuren.org</url>  
<date>2016-01-01</date>  
</note>&#39;
doc <- xmlParse(content, encoding="UTF-8")xmlToList(doc)
# use an R-level node representationdoc1 <- xmlTreeParse(content)xmlToList(doc1)
## 转换成DataFrame类型xmlToDataFrame(doc)

The results of the data frame are as follows:

            text1            
            shujuren2 
            http://shujuren.org3          
            2016-01-01

Thinking:
The address book on the mobile phone can be imported into XML data format. How to import and process it using XML in R language?
Reference link:
http://www.php.cn/xml_rss-353691.html

The above is the XML package for importing and processing XML data format|R package Content, please pay attention to the PHP Chinese website (www.php.cn) for more related content!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn