<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/new-r-package-flatxml-working-with-xml-files-as-r-dataframes/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://topics-in-r.blogspot.com/2018/06/new-r-package-flatxml-working-with-xml.html"> Topics in R</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>	<span>The world is flat</span> The new R package <i>flatxml</i> provides functions to easily deal with XML files. When parsing an XML document <i>fxml_importXMLFlat</i> produces a special dataframe that is ‘flat’ by its very nature but contains all necessary information about the hierarchical structure of the underlying XML document (for details on the dataframe see the reference for the <i>fxml_importXMLFlat</i> function). <i>flatxml</i> offers a set of functions to work with this dataframe. Apart from representing the XML document in a dataframe structure, there is yet another way in which <i>flatxml</i> relates to dataframes: the <i>fxml_toDataFrame</i> function can be used to extract data from an XML document into a dataframe, e.g. to work on the data with statistical functions. Because in this case there is no need to represent the XML document structure as such (it’s all about the data contained in the document), there is no representation of the hierarchical structure of the document any more, it’s just a normal dataframe. Each XML element, for example <i></i> has certain characteristics that can be accessed via the <i>flatxml</i> interface functions, after an XML document has been imported with \<i>fxml_importXMLFlat</i>. These characteristics are: </p>
<ul>
<li><i>value</i>: The (text) value of the element, “<i>Here is some text</i>” in the example above</li>
<li><i>attributes</i>: The XML attributes of the element, <i>attribute</i> with its value “<i>some value</i>” in the example above</li>
<li><i>children</i>: The elements on the next lower hierarchical level</li>
<li><i>parent</i>: The element of the next higher hierarchical level, i.e. the element to which the current element is a child</li>
<li><i>siblings</i>: The elements on the same hierarchical level as the current element</li>
</ul>
<p> <span>Structure of the flatxml interface</span> The <i>flatxml</i> interface to access these characteristics follows a simple logic: For each of the characteristics there are typically three functions available: </p>
<ul>
<li>fxml_has…(): Determines if the current XML element has (at least one instance of) the characteristic</li>
<li>fxml_num…(): Returns the number of the characteristics of the current XML (e.g. the number of children elements</li>
<li>fxml_get…(): Returns (the IDs of) the respective characteristics of the current XML element (e.g. the children of the current element)</li>
</ul>
<p> <span>Learn more</span> For more information on the flatxml package please go to <a rel="nofollow" href="http://www.zuckarelli.de/flatxml/index.html" target="_blank">http://www.zuckarelli.de/flatxml/index.html</a>.</p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://topics-in-r.blogspot.com/2018/06/new-r-package-flatxml-working-with-xml.html"> Topics in R</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/lhdbKwnutL0" height="1"></a></div>