<?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 NaElement instance has no attribute 'replace' in Python Discussions</title>
    <link>https://community.netapp.com/t5/Python-Discussions/NaElement-instance-has-no-attribute-replace/m-p/156894#M39</link>
    <description>&lt;P&gt;I'm trying to run a simple volume-get-iter against a number of our clusters, and then using xmltodict I want to convert the XML to a dictionary so that I can simply dump it in json format. It's working fine for all but one of our cdot clusters, but I think it's breaking on a cluster where there may be an odd character in a volume name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;File "./y.py", line 39, in &amp;lt;module&amp;gt;&lt;BR /&gt;xml_parser = out.sprintf()&lt;BR /&gt;File "/local/mnt/netappsplunk/NaElement.py", line 236, in sprintf&lt;BR /&gt;s = s+c.sprintf(indent + "\t")&lt;BR /&gt;File "/local/mnt/netappsplunk/NaElement.py", line 236, in sprintf&lt;BR /&gt;s = s+c.sprintf(indent + "\t")&lt;BR /&gt;File "/local/mnt/netappsplunk/NaElement.py", line 236, in sprintf&lt;BR /&gt;s = s+c.sprintf(indent + "\t")&lt;BR /&gt;File "/local/mnt/netappsplunk/NaElement.py", line 236, in sprintf&lt;BR /&gt;s = s+c.sprintf(indent + "\t")&lt;BR /&gt;File "/local/mnt/netappsplunk/NaElement.py", line 239, in sprintf&lt;BR /&gt;s = s + str(self.element['content'])&lt;BR /&gt;UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 30: ordinal not in range(128)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried to just do a replace, but that fails:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;out = (s.invoke_elem(volume_list)).replace('\\xa0', ' ')&lt;BR /&gt;AttributeError: NaElement instance has no attribute 'replace'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to make this work?&lt;/P&gt;</description>
    <pubDate>Wed, 04 Jun 2025 11:05:42 GMT</pubDate>
    <dc:creator>JonathanSneep</dc:creator>
    <dc:date>2025-06-04T11:05:42Z</dc:date>
    <item>
      <title>NaElement instance has no attribute 'replace'</title>
      <link>https://community.netapp.com/t5/Python-Discussions/NaElement-instance-has-no-attribute-replace/m-p/156894#M39</link>
      <description>&lt;P&gt;I'm trying to run a simple volume-get-iter against a number of our clusters, and then using xmltodict I want to convert the XML to a dictionary so that I can simply dump it in json format. It's working fine for all but one of our cdot clusters, but I think it's breaking on a cluster where there may be an odd character in a volume name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;File "./y.py", line 39, in &amp;lt;module&amp;gt;&lt;BR /&gt;xml_parser = out.sprintf()&lt;BR /&gt;File "/local/mnt/netappsplunk/NaElement.py", line 236, in sprintf&lt;BR /&gt;s = s+c.sprintf(indent + "\t")&lt;BR /&gt;File "/local/mnt/netappsplunk/NaElement.py", line 236, in sprintf&lt;BR /&gt;s = s+c.sprintf(indent + "\t")&lt;BR /&gt;File "/local/mnt/netappsplunk/NaElement.py", line 236, in sprintf&lt;BR /&gt;s = s+c.sprintf(indent + "\t")&lt;BR /&gt;File "/local/mnt/netappsplunk/NaElement.py", line 236, in sprintf&lt;BR /&gt;s = s+c.sprintf(indent + "\t")&lt;BR /&gt;File "/local/mnt/netappsplunk/NaElement.py", line 239, in sprintf&lt;BR /&gt;s = s + str(self.element['content'])&lt;BR /&gt;UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 30: ordinal not in range(128)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried to just do a replace, but that fails:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;out = (s.invoke_elem(volume_list)).replace('\\xa0', ' ')&lt;BR /&gt;AttributeError: NaElement instance has no attribute 'replace'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to make this work?&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jun 2025 11:05:42 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Python-Discussions/NaElement-instance-has-no-attribute-replace/m-p/156894#M39</guid>
      <dc:creator>JonathanSneep</dc:creator>
      <dc:date>2025-06-04T11:05:42Z</dc:date>
    </item>
    <item>
      <title>Re: NaElement instance has no attribute 'replace'</title>
      <link>https://community.netapp.com/t5/Python-Discussions/NaElement-instance-has-no-attribute-replace/m-p/156897#M40</link>
      <description>&lt;P&gt;I believe now that I should modify the sprintf function in NaElement, but i'm not sure exactly how.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 12:30:14 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Python-Discussions/NaElement-instance-has-no-attribute-replace/m-p/156897#M40</guid>
      <dc:creator>JonathanSneep</dc:creator>
      <dc:date>2020-06-11T12:30:14Z</dc:date>
    </item>
    <item>
      <title>Re: NaElement instance has no attribute 'replace'</title>
      <link>https://community.netapp.com/t5/Python-Discussions/NaElement-instance-has-no-attribute-replace/m-p/156908#M41</link>
      <description>&lt;P&gt;Solved, by adding the following to NaElement.py&lt;/P&gt;
&lt;P&gt;I'm open to other ideas or educational comments though &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;sys.setdefaultencoding('utf-8')&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 15:56:14 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Python-Discussions/NaElement-instance-has-no-attribute-replace/m-p/156908#M41</guid>
      <dc:creator>JonathanSneep</dc:creator>
      <dc:date>2020-06-11T15:56:14Z</dc:date>
    </item>
  </channel>
</rss>

