# How to prevent FXmlNode children from GC removal?

**URL:** <https://forums.unrealengine.com/t/how-to-prevent-fxmlnode-children-from-gc-removal/445134>\
**Category:** C++\
**Tags:** garbage-collector, unreal-engine, xml, question, CPP\
**Created:** [March 12, 2019, 7:42am UTC](https://forums.unrealengine.com/t/how-to-prevent-fxmlnode-children-from-gc-removal/445134 "2019-03-12T07:42:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![TimLobner](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TimLobner](https://forums.unrealengine.com/u/TimLobner)\
**Post date:** [March 12, 2019, 7:42am UTC](https://forums.unrealengine.com/t/how-to-prevent-fxmlnode-children-from-gc-removal/445134/1 "2019-03-12T07:42:32Z")

</div>

I am reading an Xml File

```
if (FPaths::FileExists(xmlPath))
{
    FXmlFile file(xmlPath);
    rootNode = file.GetRootNode();
}

```

Where rootNode is a member of the current class/object.  
Within the `if`branch, everything works fine, but as soon as I leave the if branch, the children of `rootNode` are gone, I presume the garbage collector removed them. How can I prevent this?

* * *

**EDIT**

I have rewritten my class to inherit from UObject and use the `rootNode` as a `UPROPERTY` and the problem still remains.
