HOW TO
Empty XML files are useful for creating metadata templates and for creating metadata documents describing resources that are not available online. For example, you might create an empty XML file and then use a metadata editor to add information describing a paper map, an atlas, or data that has been archived on tape.
Note: Support for Visual Basic for Applications (VBA) for ArcMap and ArcCatalog ended with the ArcGIS 10.2.2 release, and Esri has not included VBA compatibility setups since version 10.5. See: ArcGIS Desktop and VBA Moving Forward
To programmatically create an empty XML file:
Note: For more information on creating a UIControl, see the ArcGIS Desktop Help topic 'How to create custom commands with VBA'.
'Get the selected object and make sure it's a folder Dim pGxApp As IGxApplication Dim pGxObj As IGxObject Set pGxApp = Application Set pGxObj = pGxApp.SelectedObject If Not (TypeOf pGxObj Is IGxFolder) Then Exit Sub Dim sName As String Dim lCnt As Long sName = "New_XML_Document" lCnt = 1 'Count the number of objects in the folder whose names begin 'with "New_XML_Document" Dim pGxCnt As IGxObjectContainer Set pGxCnt = pGxObj If pGxCnt.HasChildren Then Dim pGxChldEn As IEnumGxObject Dim pGxChld As IGxObject Set pGxChldEn = pGxCnt.Children On Error Resume Next Set pGxChld = pGxChldEn.Next Do While Not pGxChld Is Nothing If Left(pGxChld.name, 16) = sName Then lCnt = lCnt + 1 Set pGxChld = pGxChldEn.Next Loop End If If lCnt > 1 Then sName = sName & "(" & lCnt & ")" 'Create a new GxMetadata object and give it a file name Dim pGxFile As IGxFile Set pGxFile = New GxMetadata pGxFile.path = pGxObj.FullName & "\" & sName & ".xml" 'Generate metadata for the new GxObject Dim pMD As IMetadata Dim pXPS As IXmlPropertySet Set pMD = pGxFile Set pXPS = New XmlPropertySet pMD.Metadata = pXPS 'Refresh the folder's contents pGxObj.Refresh
Get help from ArcGIS experts
Download the Esri Support App