<?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 Re: XML import: multiple value same element in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/XML-import-multiple-value-same-element/m-p/852568#M337005</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/36451"&gt;@MariaD&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The example XML you have posted is not valid XML, so that makes it hard to tell exactly what your issue is. However, I suspect you need an XML map. Here is a nice straightforward article on how to have SAS automatically create an XML map for you using the automap= option on the libname statement:&amp;nbsp;&lt;A href="https://blogs.sas.com/content/sgf/2016/06/24/tips-for-reading-xml-files-into-sas-software/" target="_blank"&gt;Tips for reading XML files into SAS® software - SAS Users&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are two issues with your XML: 1) the middle two elements do not have an element name, and 2) the middle two elements do not have closing tags. Below is some example code with two possible corrections of your XML. In either case, there are two elements with the same name, and both get imported.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;/* Create temporary files to use for the two XML files and the XML map */
filename xmlfile1 temp;
filename xmlfile2 temp;
filename mapfile temp;

/* Create the two XML files */
data _null_;
  file xmlfile1;
  put '&amp;lt;Op id="AA" MOD="214" ZIP="AAAA"&amp;gt;' /
    '&amp;lt;elementname info="122" /&amp;gt;' /
    '&amp;lt;elementname info="213" Cd="56" Ident="oooo" /&amp;gt;' /
    '&amp;lt;/Op&amp;gt;';
run;

data _null_;
  file xmlfile2;
  put '&amp;lt;Op id="AA" MOD="214" ZIP="AAAA"&amp;gt;' /
    '&amp;lt;info&amp;gt;122&amp;lt;/info&amp;gt;' /
    '&amp;lt;info Cd="56" Ident="oooo"&amp;gt;213&amp;lt;/info&amp;gt;' /
    '&amp;lt;/Op&amp;gt;';
run;

/* Import the two XML files into libraries called xmlfile1 and xmlfile2 respectively */
libname xmlfile1 xmlv2 xmlmap=mapfile automap=replace;
libname xmlfile2 xmlv2 xmlmap=mapfile automap=replace;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Hope this helps!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Joshua&lt;/P&gt;</description>
    <pubDate>Fri, 06 Jan 2023 21:09:06 GMT</pubDate>
    <dc:creator>mtnbikerjoshua</dc:creator>
    <dc:date>2023-01-06T21:09:06Z</dc:date>
    <item>
      <title>XML import: multiple value same element</title>
      <link>https://communities.sas.com/t5/SAS-Programming/XML-import-multiple-value-same-element/m-p/852134#M336853</link>
      <description>&lt;P&gt;Hi folks,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have an XML file with multiple values for the same element. For example, the element &amp;lt;Info&amp;gt; in some cases has 2 or 3 different values:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;lt;Op id="AA" MOD="214" ZIP="AAAA"&amp;gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;lt;Info="122"&amp;gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;lt;info="213" Cd="56" Ident="oooo"&amp;gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;lt;/Op&amp;gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I import the XML on SAS, the results only have the last &amp;lt;Info&amp;gt; element, in my example, 213. Is there any way to have the 2 values on SAS table?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jan 2023 16:18:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/XML-import-multiple-value-same-element/m-p/852134#M336853</guid>
      <dc:creator>MariaD</dc:creator>
      <dc:date>2023-01-04T16:18:52Z</dc:date>
    </item>
    <item>
      <title>Re: XML import: multiple value same element</title>
      <link>https://communities.sas.com/t5/SAS-Programming/XML-import-multiple-value-same-element/m-p/852568#M337005</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/36451"&gt;@MariaD&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The example XML you have posted is not valid XML, so that makes it hard to tell exactly what your issue is. However, I suspect you need an XML map. Here is a nice straightforward article on how to have SAS automatically create an XML map for you using the automap= option on the libname statement:&amp;nbsp;&lt;A href="https://blogs.sas.com/content/sgf/2016/06/24/tips-for-reading-xml-files-into-sas-software/" target="_blank"&gt;Tips for reading XML files into SAS® software - SAS Users&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are two issues with your XML: 1) the middle two elements do not have an element name, and 2) the middle two elements do not have closing tags. Below is some example code with two possible corrections of your XML. In either case, there are two elements with the same name, and both get imported.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;/* Create temporary files to use for the two XML files and the XML map */
filename xmlfile1 temp;
filename xmlfile2 temp;
filename mapfile temp;

/* Create the two XML files */
data _null_;
  file xmlfile1;
  put '&amp;lt;Op id="AA" MOD="214" ZIP="AAAA"&amp;gt;' /
    '&amp;lt;elementname info="122" /&amp;gt;' /
    '&amp;lt;elementname info="213" Cd="56" Ident="oooo" /&amp;gt;' /
    '&amp;lt;/Op&amp;gt;';
run;

data _null_;
  file xmlfile2;
  put '&amp;lt;Op id="AA" MOD="214" ZIP="AAAA"&amp;gt;' /
    '&amp;lt;info&amp;gt;122&amp;lt;/info&amp;gt;' /
    '&amp;lt;info Cd="56" Ident="oooo"&amp;gt;213&amp;lt;/info&amp;gt;' /
    '&amp;lt;/Op&amp;gt;';
run;

/* Import the two XML files into libraries called xmlfile1 and xmlfile2 respectively */
libname xmlfile1 xmlv2 xmlmap=mapfile automap=replace;
libname xmlfile2 xmlv2 xmlmap=mapfile automap=replace;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Hope this helps!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Joshua&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 21:09:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/XML-import-multiple-value-same-element/m-p/852568#M337005</guid>
      <dc:creator>mtnbikerjoshua</dc:creator>
      <dc:date>2023-01-06T21:09:06Z</dc:date>
    </item>
  </channel>
</rss>

