55namespace  DragonCode \LaravelFeed \Services ;
66
77use  DOMDocument ;
8- use  DOMElement ;
8+ use  DOMNode ;
99use  DragonCode \LaravelFeed \Feeds \Items \FeedItem ;
1010use  Illuminate \Container \Attributes \Config ;
1111use  Illuminate \Support \Str ;
@@ -31,7 +31,7 @@ public function __construct(
3131        $ this  ->document ->preserveWhiteSpace  = ! $ pretty ;
3232    }
3333
34-     public  function  convert (FeedItem   $ item ): string 
34+     public  function  convertItem (FeedItem   $ item ): string 
3535    {
3636        $ box  = $ this  ->performBox ($ item );
3737
@@ -40,7 +40,16 @@ public function convert(FeedItem $item): string
4040        return  $ this  ->toXml ($ box );
4141    }
4242
43-     protected  function  performBox (FeedItem   $ item ): DOMElement 
43+     public  function  convertInfo (array  $ info ): string 
44+     {
45+         $ box  = $ this  ->document ->createDocumentFragment ();
46+ 
47+         $ this  ->performItem ($ box , $ info );
48+ 
49+         return  $ this  ->toXml ($ box );
50+     }
51+ 
52+     protected  function  performBox (FeedItem   $ item ): DOMNode 
4453    {
4554        $ element  = $ this  ->createElement ($ item ->name ());
4655
@@ -51,7 +60,7 @@ protected function performBox(FeedItem $item): DOMElement
5160        return  $ element ;
5261    }
5362
54-     protected  function  performItem (DOMElement   $ parent , array  $ items ): void 
63+     protected  function  performItem (DOMNode   $ parent , array  $ items ): void 
5564    {
5665        foreach  ($ items  as  $ key  => $ value ) {
5766            $ key  = $ this  ->convertKey ($ key );
@@ -92,34 +101,34 @@ protected function isPrefixed(string $key): bool
92101        return  str_starts_with ($ key , '@ ' );
93102    }
94103
95-     protected  function  createElement (string  $ name , bool |float |int |string |null  $ value  = '' ): DOMElement 
104+     protected  function  createElement (string  $ name , bool |float |int |string |null  $ value  = '' ): DOMNode 
96105    {
97106        return  $ this  ->document ->createElement ($ name , $ this  ->convertValue ($ value ));
98107    }
99108
100-     protected  function  setAttributes (DOMElement   $ element , array  $ attributes ): void 
109+     protected  function  setAttributes (DOMNode   $ element , array  $ attributes ): void 
101110    {
102111        foreach  ($ attributes  as  $ key  => $ value ) {
103112            $ element ->setAttribute ($ key , $ this  ->convertValue ($ value ));
104113        }
105114    }
106115
107-     protected  function  setCData (DOMElement   $ element , string  $ value ): void 
116+     protected  function  setCData (DOMNode   $ element , string  $ value ): void 
108117    {
109118        $ element ->appendChild (
110119            $ this  ->document ->createCDATASection ($ value )
111120        );
112121    }
113122
114-     protected  function  setMixed (DOMElement   $ element , string  $ value ): void 
123+     protected  function  setMixed (DOMNode   $ element , string  $ value ): void 
115124    {
116125        $ fragment  = $ this  ->document ->createDocumentFragment ();
117126        $ fragment ->appendXML ($ value );
118127
119128        $ element ->appendChild ($ fragment );
120129    }
121130
122-     protected  function  setItemsArray (DOMElement   $ parent , $ value , string  $ key ): void 
131+     protected  function  setItemsArray (DOMNode   $ parent , $ value , string  $ key ): void 
123132    {
124133        $ key  = Str::substr ($ key , 1 );
125134
@@ -128,7 +137,7 @@ protected function setItemsArray(DOMElement $parent, $value, string $key): void
128137        }
129138    }
130139
131-     protected  function  setItems (DOMElement   $ parent , string  $ key , mixed  $ value ): void 
140+     protected  function  setItems (DOMNode   $ parent , string  $ key , mixed  $ value ): void 
132141    {
133142        $ element  = $ this  ->createElement ($ key , is_array ($ value ) ? ''  : $ this  ->convertValue ($ value ));
134143
@@ -139,14 +148,14 @@ protected function setItems(DOMElement $parent, string $key, mixed $value): void
139148        $ parent ->appendChild ($ element );
140149    }
141150
142-     protected  function  setRaw (DOMElement   $ parent , mixed  $ value ): void 
151+     protected  function  setRaw (DOMNode   $ parent , mixed  $ value ): void 
143152    {
144153        $ parent ->nodeValue  = $ this  ->convertValue ($ value );
145154    }
146155
147-     protected  function  toXml (DOMElement   $ item ): string 
156+     protected  function  toXml (DOMNode   $ item ): string 
148157    {
149-         return  $ this  ->document ->saveXML ($ item );
158+         return  $ this  ->document ->saveXML ($ item,  LIBXML_COMPACT );
150159    }
151160
152161    protected  function  convertKey (int |string  $ key ): string 
0 commit comments