<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Create XML file, change root tag in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-XML-file-change-root-tag/m-p/596525#M171764</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm creating a XML file using the XMLV2 library engine. The code looks like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;FILENAME MyXML "&amp;amp;dir.\kip.xml" ;
LIBNAME MyXML XMLV2 XMLENCODING=utf8 ;

DATA MyXML.Klas ;
  SET sashelp.class (OBS=1) ;
RUN ;

LIBNAME MyXML CLEAR ;
FILENAME MyXML CLEAR ;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It successfully creates a XML file. However I would like to change 2 things. If you look at the XML file&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;lt;?xml version="1.0" encoding="utf-8" ?&amp;gt;
&amp;lt;TABLE&amp;gt;
   &amp;lt;KLAS&amp;gt;
      &amp;lt;Name&amp;gt;Alfred&amp;lt;/Name&amp;gt;
      &amp;lt;Sex&amp;gt;M&amp;lt;/Sex&amp;gt;
      &amp;lt;Age&amp;gt;14&amp;lt;/Age&amp;gt;
      &amp;lt;Height&amp;gt;69&amp;lt;/Height&amp;gt;
      &amp;lt;Weight&amp;gt;112.5&amp;lt;/Weight&amp;gt;
   &amp;lt;/KLAS&amp;gt;
&amp;lt;/TABLE&amp;gt;&lt;/PRE&gt;&lt;P&gt;I would like to change the root tag to Klassen and the upcase KLAS to Klas. So it looks like this:&lt;/P&gt;&lt;PRE&gt;&amp;lt;?xml version="1.0" encoding="utf-8" ?&amp;gt;
&amp;lt;Klassen&amp;gt;
   &amp;lt;Klas&amp;gt;
      &amp;lt;Name&amp;gt;Alfred&amp;lt;/Name&amp;gt;
      &amp;lt;Sex&amp;gt;M&amp;lt;/Sex&amp;gt;
      &amp;lt;Age&amp;gt;14&amp;lt;/Age&amp;gt;
      &amp;lt;Height&amp;gt;69&amp;lt;/Height&amp;gt;
      &amp;lt;Weight&amp;gt;112.5&amp;lt;/Weight&amp;gt;
   &amp;lt;/Klas&amp;gt;
&amp;lt;/Klassen&amp;gt;&lt;/PRE&gt;&lt;P&gt;Is there any way to do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thierry&lt;/P&gt;</description>
    <pubDate>Tue, 15 Oct 2019 13:47:34 GMT</pubDate>
    <dc:creator>ThierryHerrie</dc:creator>
    <dc:date>2019-10-15T13:47:34Z</dc:date>
    <item>
      <title>Create XML file, change root tag</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-XML-file-change-root-tag/m-p/596525#M171764</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm creating a XML file using the XMLV2 library engine. The code looks like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;FILENAME MyXML "&amp;amp;dir.\kip.xml" ;
LIBNAME MyXML XMLV2 XMLENCODING=utf8 ;

DATA MyXML.Klas ;
  SET sashelp.class (OBS=1) ;
RUN ;

LIBNAME MyXML CLEAR ;
FILENAME MyXML CLEAR ;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It successfully creates a XML file. However I would like to change 2 things. If you look at the XML file&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;lt;?xml version="1.0" encoding="utf-8" ?&amp;gt;
&amp;lt;TABLE&amp;gt;
   &amp;lt;KLAS&amp;gt;
      &amp;lt;Name&amp;gt;Alfred&amp;lt;/Name&amp;gt;
      &amp;lt;Sex&amp;gt;M&amp;lt;/Sex&amp;gt;
      &amp;lt;Age&amp;gt;14&amp;lt;/Age&amp;gt;
      &amp;lt;Height&amp;gt;69&amp;lt;/Height&amp;gt;
      &amp;lt;Weight&amp;gt;112.5&amp;lt;/Weight&amp;gt;
   &amp;lt;/KLAS&amp;gt;
&amp;lt;/TABLE&amp;gt;&lt;/PRE&gt;&lt;P&gt;I would like to change the root tag to Klassen and the upcase KLAS to Klas. So it looks like this:&lt;/P&gt;&lt;PRE&gt;&amp;lt;?xml version="1.0" encoding="utf-8" ?&amp;gt;
&amp;lt;Klassen&amp;gt;
   &amp;lt;Klas&amp;gt;
      &amp;lt;Name&amp;gt;Alfred&amp;lt;/Name&amp;gt;
      &amp;lt;Sex&amp;gt;M&amp;lt;/Sex&amp;gt;
      &amp;lt;Age&amp;gt;14&amp;lt;/Age&amp;gt;
      &amp;lt;Height&amp;gt;69&amp;lt;/Height&amp;gt;
      &amp;lt;Weight&amp;gt;112.5&amp;lt;/Weight&amp;gt;
   &amp;lt;/Klas&amp;gt;
&amp;lt;/Klassen&amp;gt;&lt;/PRE&gt;&lt;P&gt;Is there any way to do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thierry&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2019 13:47:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-XML-file-change-root-tag/m-p/596525#M171764</guid>
      <dc:creator>ThierryHerrie</dc:creator>
      <dc:date>2019-10-15T13:47:34Z</dc:date>
    </item>
    <item>
      <title>Re: Create XML file, change root tag</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-XML-file-change-root-tag/m-p/596536#M171769</link>
      <description>&lt;P&gt;You probably will need to create a map file.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?docsetId=engxml&amp;amp;docsetTarget=p030dni55gms3qn1xxc7xxpzn06p.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en"&gt;https://documentation.sas.com/?docsetId=engxml&amp;amp;docsetTarget=p030dni55gms3qn1xxc7xxpzn06p.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or you could just post-process the file.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile  "&amp;amp;dir.\kip.xml" ;
  file  "&amp;amp;dir.\kip_fixed.xml" ;
  input ;
  if _infile_ = '&amp;lt;TABLE&amp;gt;' then _infile_='&amp;lt;Klassen&amp;gt;';
  else if _infile_ = '&amp;lt;/TABLE&amp;gt;' then _infile_='&amp;lt;/Klassen&amp;gt;';
  else if left(_infile_)='&amp;lt;KLAS&amp;gt;' then _infile_='&amp;lt;Klas&amp;gt;';
  else if left(_infile_)='&amp;lt;/KLAS&amp;gt;' then _infile_='&amp;lt;/Klas&amp;gt;';
  put _infile_;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Oct 2019 14:14:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-XML-file-change-root-tag/m-p/596536#M171769</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-10-15T14:14:13Z</dc:date>
    </item>
    <item>
      <title>Re: Create XML file, change root tag</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-XML-file-change-root-tag/m-p/596607#M171805</link>
      <description>&lt;P&gt;Postprocessing the file was my plan B&amp;nbsp;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;Think I will just do that, thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2019 17:40:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-XML-file-change-root-tag/m-p/596607#M171805</guid>
      <dc:creator>ThierryHerrie</dc:creator>
      <dc:date>2019-10-15T17:40:17Z</dc:date>
    </item>
  </channel>
</rss>

