I have the following situation:
I need to add a child element to an existing XML tag.
my current XML looks like this: it contains an empty (self-closing) " <attr tag=.../>
":
<?xml version="1.0" encoding="UTF-8"?>
<dataset>
...
<attr tag="00081110" vr="SQ" pos="-1" name="Referenced Study Sequence" len="-1"/>
...
</dataset>
after conversion it should look something like this: 2 children added / inserted (wrapped by the element <item>
):
<?xml version="1.0" encoding="UTF-8"?>
<dataset>
...
<attr tag="00081110" vr="SQ" pos="-1" name="Referenced Study Sequence" len="-1">
<item id="1" pos="28" len="-1">
<attr tag="00081150" vr="UI" pos="36" name="Referenced SOP Class UID" vm="0" len="3">991</attr>
<attr tag="00081155" vr="UI" pos="44" name="Referenced SOP Instance UID" vm="0" len="3">992</attr>
</item>
</attr>
...
</dataset>
How can i achieve this? I tried various random settings, but in my best shot I ended up replacing the parent (tag = "00081110") with a child.
source
share