# How to get a grouped representation xml with an audio processor value tree state

**URL:** <https://forum.juce.com/t/how-to-get-a-grouped-representation-xml-with-an-audio-processor-value-tree-state/33986>\
**Category:** General JUCE discussion\
**Created:** [June 18, 2019, 4:12pm UTC](https://forum.juce.com/t/how-to-get-a-grouped-representation-xml-with-an-audio-processor-value-tree-state/33986 "2019-06-18T16:12:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DEADBEEF](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@DEADBEEF](https://forum.juce.com/u/DEADBEEF)\
**Post date:** [June 18, 2019, 4:12pm UTC](https://forum.juce.com/t/how-to-get-a-grouped-representation-xml-with-an-audio-processor-value-tree-state/33986/1 "2019-06-18T16:12:14Z")

</div>

Hi folks,

I’m currently using an `audioprocessorvaluetreestate` to manage several effect parameters.  
I would like to export my effect settings from the value tree to a xml file.  
We all know that the effects are stored like this:

```
<Identifier>
  <PARAM id="CompressorAttack" value="1.0"/>
  <PARAM id="CompressorRatio" value="50.0"/>
  <PARAM id="FilterCuttOff" value="0.5"/>
  <PARAM id="FilterQ" value="0.8"/>
</Identifier>

```

But would it be possible to use `AudioProcessorParameterGroups` and get a representation like this:

```
<ParameterGroups>
          <Group name="Compressor">
            <Parameter id="CompressorAttack" value="1.0"/>
            <Parameter id="CompressorRatio" value="50.0"/>
          </Group>
          <Group name="Filter">
            <Parameter id="FilterCuttOff" value="0.5"/>
            <Parameter id="FilterQ" value="0.8"/>
          </Group>
</ParameterGroups>

```

So far I found that this representation was possible with a value tree using this method:  
`ValueTree (const Identifier& type, std::initializer_list<NamedValueSet::NamedValue> properties, std::initializer_list<ValueTree> subTrees = {});`

But then I cannot use `audioprocessorvaluetreestate`.  
If I init `audioprocessorvaluetreestate` with `AudioProcessorParameterGroups` I still don’t get the desired representation and the juce source code seems to indicate that the group feature is not used by the internal value tree.

I’m looking for getting the desired representation with this kind of call:  
`audioprocessorvaluetreestate.state.toXmlString()`

Would you have an idea to get this representation?

---

<div class="post-metadata">

**Author:** ![DEADBEEF](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@DEADBEEF](https://forum.juce.com/u/DEADBEEF)\
**Post date:** [June 21, 2019, 5:56pm UTC](https://forum.juce.com/t/how-to-get-a-grouped-representation-xml-with-an-audio-processor-value-tree-state/33986/2 "2019-06-21T17:56:59Z")

</div>

I’m still trying to resolve this. Nobody already encountered this kind of issue?

---

<div class="post-metadata">

**Author:** ![t0m](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/t0m/32/16413_2.png) [@t0m](https://forum.juce.com/u/t0m)\
**Post date:** [June 27, 2019, 11:25am UTC](https://forum.juce.com/t/how-to-get-a-grouped-representation-xml-with-an-audio-processor-value-tree-state/33986/3 "2019-06-27T11:25:22Z")

</div>

What do you want to use the XML for?

You can iterate over the parameter tree to do this:

```
std::function<void(const AudioProcessorParameterGroup&, XmlElement&)> createGroups;
createGroups = [&createGroups](const AudioProcessorParameterGroup& apGroup, XmlElement& xmlGroup)
{
    for (auto node : apGroup)
    {
        if (auto group = node->getGroup())
        {
            auto element = xmlGroup.createNewChildElement ("GROUP");
            element->setAttribute ("name", group->getName());
            createGroups (*group, *element);
        }
        else if (auto parameter = node->getParameter())
        {
            auto element = xmlGroup.createNewChildElement ("PARAMETER");
            element->setAttribute ("name", parameter->getName (256));
            element->setAttribute ("value", parameter->getValue());
        }
    }
};

XmlElement root ("ROOT");
createGroups (getParameterTree(), root);
std::cout << root.toString();
```

---

<div class="post-metadata">

**Author:** ![DEADBEEF](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@DEADBEEF](https://forum.juce.com/u/DEADBEEF)\
**Post date:** [October 13, 2019, 4:22pm UTC](https://forum.juce.com/t/how-to-get-a-grouped-representation-xml-with-an-audio-processor-value-tree-state/33986/4 "2019-10-13T16:22:37Z")

</div>

Thanks for your reply. I’m really sorry for replying to you only now but the project was kind of abandoned and I’ve been away from JUCE dev this last weeks.

The goal of this is to export parameters data as a XML or JSON in a formatted architecture that will be parsed by an external service.  
That’s the reason I cannot use the simple representation I mentioned first.

Thanks for your exemple I will try it when the project will come back to life in few weeks I guess.
