<?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 Metadata: ItemDescription M=missing 'dataIdInfo' xml element (among others) in Geodatabase Questions</title>
    <link>https://community.esri.com/t5/geodatabase-questions/metadata-itemdescription-m-missing-dataidinfo-xml/m-p/1056826#M7175</link>
    <description>&lt;P&gt;I was in a flow updating metadata for feature classes within a file geodatabase.&amp;nbsp; In this process I renamed and moved multiple feature classes either within a gdb or from one gdb to another.&amp;nbsp; Now I am updating the Item Description using ElementTree and Python, BUT for some reason multiple feature classes are missing every xml element except "ESRI".&amp;nbsp; IN particular "dataIdInfo" is what I have updated successfully many, many times.&amp;nbsp; I will attach some code to show my methodology, but the issue is that multiple feature classes have no metadata basically - "refSysInfo", "mdLang", mdChar" - literally every core metadata item is missing from the xml tree save for the "ESRI" Parent (??).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;1) BAD XML&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="bad_xml.JPG" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/13062i805CE6F030D50395/image-size/medium?v=v2&amp;amp;px=400" role="button" title="bad_xml.JPG" alt="bad_xml.JPG" /&gt;&lt;/span&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;2) NORMAL XML (&lt;/U&gt;notice dataIdInfo and everything that follows)&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="normal_xml.JPG" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/13063i84D1A6400692C267/image-size/medium?v=v2&amp;amp;px=400" role="button" title="normal_xml.JPG" alt="normal_xml.JPG" /&gt;&lt;/span&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an example of my workflow BUT it's not my problem - above screenshot is the issue - script just for context if interested.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import xml.etree.ElementTree as ET
import arcpy
import copy

# 1) get xml from fcs
fp_fcs = 'path/to/gdb/feature_class'
temp_path = copy.copy(fp_fcs)
tgt_item_md = arcpy.metadata.Metadata(fp_fcs)
fp_xml = arcpy.CreateScratchName('.xml', workspace = arcpy.env.scratchFolder)
# copy xml of feature class -- next up - update it
tgt_item_md.saveAsXML(fp_xml, 'EXACT_COPY')

# 2) Update tree with new metadata
tree = ET.parse(fp_xml)
root = tree.getroot()
# Always in xml file - until today? This will return a NONE object
dataIdInfo = root.find('dataIdInfo')
# This will fail --&amp;gt; "None object does not have method find"
purp = dataIdInfo.find('idPurp')

# BUT when it's working I do this:
# update purpose subelement
el = ET.SubElement(dataIdInfo, 'idPurp)
el.text = 'my new purpose text block'
# write to scratch xml
ET.dump(dataIdInfo)
tree.write(fp_xml)

# 3) Apply updated xml to orig fcs and save
# Apply to fcs
# now that xml is updated, pull new xml
src_template_md = arcpy.metadata.Metadata(fp_xml)
# add updated xml to feature class xml 
tgt_item_md.copy(src_template_md)
tgt_item_md.save()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm hoping there is a tool/function that can update BAD to NORMAL xml - like an update gdb metadata.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Help is ABUNDANTLY APPRECIATED!&amp;nbsp; Thanks...&lt;/P&gt;</description>
    <pubDate>Tue, 11 May 2021 18:55:29 GMT</pubDate>
    <dc:creator>ZacharyUhlmann1</dc:creator>
    <dc:date>2021-05-11T18:55:29Z</dc:date>
    <item>
      <title>Metadata: ItemDescription M=missing 'dataIdInfo' xml element (among others)</title>
      <link>https://community.esri.com/t5/geodatabase-questions/metadata-itemdescription-m-missing-dataidinfo-xml/m-p/1056826#M7175</link>
      <description>&lt;P&gt;I was in a flow updating metadata for feature classes within a file geodatabase.&amp;nbsp; In this process I renamed and moved multiple feature classes either within a gdb or from one gdb to another.&amp;nbsp; Now I am updating the Item Description using ElementTree and Python, BUT for some reason multiple feature classes are missing every xml element except "ESRI".&amp;nbsp; IN particular "dataIdInfo" is what I have updated successfully many, many times.&amp;nbsp; I will attach some code to show my methodology, but the issue is that multiple feature classes have no metadata basically - "refSysInfo", "mdLang", mdChar" - literally every core metadata item is missing from the xml tree save for the "ESRI" Parent (??).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;1) BAD XML&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="bad_xml.JPG" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/13062i805CE6F030D50395/image-size/medium?v=v2&amp;amp;px=400" role="button" title="bad_xml.JPG" alt="bad_xml.JPG" /&gt;&lt;/span&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;2) NORMAL XML (&lt;/U&gt;notice dataIdInfo and everything that follows)&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="normal_xml.JPG" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/13063i84D1A6400692C267/image-size/medium?v=v2&amp;amp;px=400" role="button" title="normal_xml.JPG" alt="normal_xml.JPG" /&gt;&lt;/span&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an example of my workflow BUT it's not my problem - above screenshot is the issue - script just for context if interested.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import xml.etree.ElementTree as ET
import arcpy
import copy

# 1) get xml from fcs
fp_fcs = 'path/to/gdb/feature_class'
temp_path = copy.copy(fp_fcs)
tgt_item_md = arcpy.metadata.Metadata(fp_fcs)
fp_xml = arcpy.CreateScratchName('.xml', workspace = arcpy.env.scratchFolder)
# copy xml of feature class -- next up - update it
tgt_item_md.saveAsXML(fp_xml, 'EXACT_COPY')

# 2) Update tree with new metadata
tree = ET.parse(fp_xml)
root = tree.getroot()
# Always in xml file - until today? This will return a NONE object
dataIdInfo = root.find('dataIdInfo')
# This will fail --&amp;gt; "None object does not have method find"
purp = dataIdInfo.find('idPurp')

# BUT when it's working I do this:
# update purpose subelement
el = ET.SubElement(dataIdInfo, 'idPurp)
el.text = 'my new purpose text block'
# write to scratch xml
ET.dump(dataIdInfo)
tree.write(fp_xml)

# 3) Apply updated xml to orig fcs and save
# Apply to fcs
# now that xml is updated, pull new xml
src_template_md = arcpy.metadata.Metadata(fp_xml)
# add updated xml to feature class xml 
tgt_item_md.copy(src_template_md)
tgt_item_md.save()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm hoping there is a tool/function that can update BAD to NORMAL xml - like an update gdb metadata.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Help is ABUNDANTLY APPRECIATED!&amp;nbsp; Thanks...&lt;/P&gt;</description>
      <pubDate>Tue, 11 May 2021 18:55:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/geodatabase-questions/metadata-itemdescription-m-missing-dataidinfo-xml/m-p/1056826#M7175</guid>
      <dc:creator>ZacharyUhlmann1</dc:creator>
      <dc:date>2021-05-11T18:55:29Z</dc:date>
    </item>
  </channel>
</rss>

