File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 22namespace TheSeer \Tokenizer ;
33
44use DOMDocument ;
5+ use XMLWriter ;
56
67class XMLSerializer {
78
@@ -32,6 +33,13 @@ public function toXML(TokenCollection $tokens): string {
3233 $ writer = new \XMLWriter ();
3334 $ writer ->openMemory ();
3435 $ writer ->setIndent (true );
36+
37+ $ this ->appendToWriter ($ writer , $ tokens );
38+
39+ return $ writer ->outputMemory ();
40+ }
41+
42+ public function appendToWriter (XMLWriter $ writer , TokenCollection $ tokens ): void {
3543 $ writer ->startDocument ();
3644 $ writer ->startElement ('source ' );
3745 $ writer ->writeAttribute ('xmlns ' , $ this ->xmlns ->asString ());
@@ -68,7 +76,5 @@ public function toXML(TokenCollection $tokens): string {
6876
6977 $ writer ->endElement ();
7078 $ writer ->endDocument ();
71-
72- return $ writer ->outputMemory ();
7379 }
7480}
You can’t perform that action at this time.
0 commit comments