Use greedy <svg>...</svg> match preferring closing tag over inner /> to prevent truncation at first self-closing child element. Self-closing root <svg .../> handled as separate alternative. Added test with <path/> + <circle/> children asserting well-formed output.