SVG - Wrap elements in group

Calcutualia

New Member
Want to wrap a group of svg elements inside as new group. Problem is that the new group not has a close tag. And how to get it wrapped into the new group, on this moment it will be added to the end.php code:\[code\]<?php $lagen = array();$dom = new DOMDocument;$dom->load("00000000001.svg"); $source= $dom->getElementsByTagName("g")->item(0); $newdom = new DOMDocument;$newdom->formatOutput = true;$svg = $newdom->createElement("svg");$newdom->appendChild($svg); $root = $newdom->createElement("g");$root->setAttribute("id", "dcroot");$root->setAttribute("display", "visible");$newdom->documentElement->appendChild($source); $node = $newdom->importNode($parent, true);$newdom->documentElement->appendChild($node);echo $newdom->save("test.svg");?> \[/code\]Orginal svg:\[code\]<g id="laag"><path d="M363.92 496.92L363.92 496.31 363.66 496.46 363.92 496.92Z" fill-rule="evenodd" fill="gray"/><path d="M363.92 496.92L386.43 535.88 363.92 496.31 363.92 496.92Z" fill-rule="evenodd" fill="gray"/><path d="M386.43 535.88L386.43 483.3 363.92 496.31 386.43 535.88Z" fill-rule="evenodd" fill="gray"/><path d="M386.43 535.88L470.68 681.69 386.43 483.3 386.43 535.88Z" fill-rule="evenodd" fill="gray"/><path d="M470.68 681.69L470.68 629.12 386.43 483.3 470.68 681.69Z" fill-rule="evenodd" fill="gray"/><path d="M470.68 681.69L493.45 668.53 470.68 629.12 470.68 681.69Z" fill-rule="evenodd" fill="gray"/></g>\[/code\]output what i need:\[code\]<g id="wrapper"><g id="laag"><path d="M363.92 496.92L363.92 496.31 363.66 496.46 363.92 496.92Z" fill-rule="evenodd" fill="gray"/><path d="M363.92 496.92L386.43 535.88 363.92 496.31 363.92 496.92Z" fill-rule="evenodd" fill="gray"/><path d="M386.43 535.88L386.43 483.3 363.92 496.31 386.43 535.88Z" fill-rule="evenodd" fill="gray"/><path d="M386.43 535.88L470.68 681.69 386.43 483.3 386.43 535.88Z" fill-rule="evenodd" fill="gray"/><path d="M470.68 681.69L470.68 629.12 386.43 483.3 470.68 681.69Z" fill-rule="evenodd" fill="gray"/><path d="M470.68 681.69L493.45 668.53 470.68 629.12 470.68 681.69Z" fill-rule="evenodd" fill="gray"/></g></g>\[/code\]
 
Back
Top