# How to fill tree from xml file

**URL:** <https://root-forum.cern.ch/t/how-to-fill-tree-from-xml-file/57279>\
**Category:** Newbie\
**Tags:** root\
**Created:** [November 27, 2023, 12:54pm UTC](https://root-forum.cern.ch/t/how-to-fill-tree-from-xml-file/57279 "2023-11-27T12:54:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Goktug\_Bayram](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/goktug_bayram/32/31211_2.png) [@Goktug\_Bayram](https://root-forum.cern.ch/u/Goktug_Bayram)\
**Post date:** [November 27, 2023, 12:54pm UTC](https://root-forum.cern.ch/t/how-to-fill-tree-from-xml-file/57279/1 "2023-11-27T12:54:31Z")

</div>

A couple months ago I write a code that it get data from txt file and writes to tree. Now I want to write code that do the same thing but instead of getting data from txt file, I need to do get data from xml file and write to tree. I found a example written by Sergey Linev on root.cern but I couldn’t understand what am I looking in that code. [ROOT: tutorials/xml/xmlreadfile.C File Reference](https://root.cern/doc/master/xmlreadfile_8C.html)  
Is there any simple way to do it ?  
Thanks in advance

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [November 27, 2023, 1:41pm UTC](https://root-forum.cern.ch/t/how-to-fill-tree-from-xml-file/57279/2 "2023-11-27T13:41:44Z")

</div>

Hi,

You can use tutorial as starting point.  
It demonstrates how XML file can be parsed and values from sub-nodes can be extracted.

If you plan to use really large XML files (over 1GB),  
you probably need to use SAX interface of libxml2.  
See [ROOT: tutorials/xml/SAXHandler.C File Reference](https://root.cern/doc/v628/SAXHandler_8C.html)

Regards,  
Sergey
