-
Lets say my XmlElement was based on this: <XML>
<BOX>
<IMG>
<BLUR />
<URL value="./" />
</IMG>
</BOX>
</XML> I want to modify it to remove the <XML>
<BOX>
<BLUR>
<IMG>
<URL value="./" />
</IMG>
</BLUR>
</BOX>
</XML> I have a semi working piece of code but its fairly messy and I wanted to see if there was a better way. Currently I am traversing down to the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This works for me: final actual = XmlDocument.parse('<XML><BOX><IMG><BLUR /><URL value="./" /></IMG></BOX></XML>');
final image = actual.findAllElements('IMG').single;
final blur = image.findAllElements('BLUR').single;
image.children.remove(blur);
image.replace(blur);
blur.children.add(image);
final expected = XmlDocument.parse('<XML><BOX><BLUR><IMG><URL value="./" /></IMG></BLUR></BOX></XML>');
expect(expected.toXmlString(), actual.toXmlString()); |
Beta Was this translation helpful? Give feedback.
This works for me: