Best way to manipulate XML file

Hi, I’m Kind of a newbie and this is my first post.

I’ll start off explaining what i want to do first;
I want to open an existing XML file on the users storage (that’s always located in the documents folder) and add a child element at a certain place and save it. For example:

<?xml version="1.0" encoding="utf-8"?>
<dummyXML>
	<dummyChild1 attr="one"/>
	<dummyChild2 attr="two"/>
	<dummyParam attr="param">
		<param attr="things"/>
		<param attr="things"/>
		<param attr="things"/>
//////////////////////////////////   << child element
		<param attr="things"/>
	</dummyParam>
</dummyXML>

My idea was to load the XML file, parse it, add the element if i hit an if statement.
So i’m currently making my own XML manipulator class but i’m stuck trying to parse the XML in the first place. These are my functions:

void GetResolumePreferences::load()
{
    File f = getXmlFile();
    if (f.exists())
    {
        //read in the xml data
        XmlDocument dataDoc ( f );
        configXML = dataDoc.getDocumentElement();// [1] ERROR
    }
}

File GetResolumePreferences::getXmlFile ()
{
    //get the file config.xml from the users documents folder
    File appDir = File::getSpecialLocation(File::userDocumentsDirectory);
    File xmlFile = appDir.getChildFile("Resolume Arena 6/Preferences/config.xml");
    return xmlFile;
}

my function initialisers in my header file:

public:
    
    GetResolumePreferences ();
    ~GetResolumePreferences ();
    bool save ();
    void load();
    
private:
    File getXmlFile ();
    ScopedPointer<XmlElement> configXML;

[1] (!) this gives me a No viable overloaded '=' error

So my question is, am i on the right track or is there an easier way to do this?
If so how do i correctly parse an XML file

About your error: Since ScopedPointer is deprecated, the getDocumentElement() returns a std::unique_ptr<juce::XmlElement>. They are unrelated, so you have to change your member variable.

XmlDocument::getDocumentElement returns a std::unique_ptr<XmlElement> these days, not a scoped pointer.

Thanks everyone! It seems i have found my answer. I changed my Scoped pointer to a

std::unique_ptr<XmlElement> loadedConfigXml;

that way in my load() function i can do this:

loadedConfigXml = juce::parseXML (f);

and parse the unique pointer like this:

for (auto* childElementVariableName = loadedConfigXml->getFirstChildElement(); \
     childElementVariableName != nullptr; \
     childElementVariableName = childElementVariableName->getNextElement())
{
}