How to remove HTML tags from Metadata description field

3027
12
Jump to solution
07-06-2022 08:33 AM
David_Brooks
MVP Regular Contributor

When adding a description to a layer's metadata and publishing as a Map Service to Portal, the rest endpoint shows the HTML tags for the Description and makes it very difficult to read. Is there a way of removing these tags or converting the description field to a simple plain text box? This isn't the case for the summary field.

Otherwise, is there a better way of viewing individual layer metadata for a multi-layer map service other than via the rest endpoint?


David
..Maps with no limits..
2 Solutions

Accepted Solutions
ChristianBPedersen
Occasional Contributor II

We have found an workaround for this issue which is unfortunately time consuming as every layer has to be updated with this method.

The workaround is to select the affected map or layer in the Catalog View and do an Export of the metadata to an xml file. We used the FGDC CSDGM format. Then do an Import for the same affected map / layer with the exported file and republish the service.

After this we could confirm that the issue with the HTML TAG disappeared from the map service.

2022-08-29_11-51-29.png

Christian Brogaard Pedersen

View solution in original post

Tags (2)
0 Kudos
David_Brooks
MVP Regular Contributor

Here you go:

import arcpy, os
from arcpy import metadata as md
dataset = arcpy.GetParameterAsText(0)
   
src_item_md = md.Metadata(dataset)
outXML = r'C:\\Temp\Metadata.xml'
src_item_md.exportMetadata(outXML)
 
# Import the standard-format metadata content to the target item
if not src_item_md.isReadOnly:
    src_item_md.importMetadata(outXML)
    src_item_md.save()
arcpy.management.Delete(outXML)
arcpy.AddMessage("Finished.")

 


David
..Maps with no limits..

View solution in original post

12 Replies
MCameron
Esri Contributor

Hi David, 

 

Could I ask if the behaviour is that the published service details, when viewing the REST API of the service,  shows the metadata description as having HTML tags, rather than the text that has been typed into the field in ArcGIS Pro before publishing?


If so, could I also ask if the service was published using ArcGIS Pro or ArcMap? And what version of ArcGIS Enterprise are you using?

 

There is a known bug for this issue that occurs when publishing service from ArcGIS Pro to ArcGIS Enterprise, and the workaround suggested is to remove the text in the description field before publishing the service, and complete the description from the item details page in ArcGIS Portal.

0 Kudos
AdrianMarsden
Occasional Contributor III

So the tags are a bug?  Any fix in sight?  It has broken our Javascript API internal mapping application which builds on the description data a HTML link - so having rogue HTML in the description has just broken things big time.

I note that layers imported from ArcGIS MXD are ok as we only noticed it when we added new ones.  I'll be logging an Esri(UK) call so we have visibility of this an know when it is fixed.

I would strongly suggest that this topic isn't marked "Solved" as the work around seems to be geared up for the meta data stored with the layer, not added in the Project.

AdrianMarsden
Occasional Contributor III

For info this is Esri BUG-000129415 

I've workaround the issue in my code with a very simple js function that strips html out of a string.

0 Kudos
David_Brooks
MVP Regular Contributor

@MCameron this is from the layer metadata in Pro, being viewed in the REST on the web.

So in this example, i have a layer in my service with the following metadata:

David_Brooks_0-1657209234707.png

We want the metadata for our individual layers to persist through to Enterprise, but the only way to view the Description for the individual layers is in the REST (unless someone can correct me otherwise?).

David_Brooks_1-1657209378880.png

Obviously it's not easy reading the text in the description when it's wrapped in HTML tags. So is there a better way of viewing the metadata on the individual layers? or a way of making the description field plain text (does that remove the html tags?)


David
..Maps with no limits..
ChristianBPedersen
Occasional Contributor II

We are also encounting this problem and haven't found a way to remove it. It's a problematic issue that is causing a mess in the GetCapabilities info of the hosted service. The Enterprise portal is not involved in this.

<Abstract>
<![CDATA[ <DIV STYLE="text-align:Left;font-size:12pt"><P><SPAN>

The service was hosted from ArcGIS Pro v. 3.0.1 to our ArcGIS Server Site through an ArcGIS Server Connection (.ags).

2022-08-29_09-54-40.png

2022-08-29_08-53-16.png

Christian Brogaard Pedersen
0 Kudos
ChristianBPedersen
Occasional Contributor II

We have found an workaround for this issue which is unfortunately time consuming as every layer has to be updated with this method.

The workaround is to select the affected map or layer in the Catalog View and do an Export of the metadata to an xml file. We used the FGDC CSDGM format. Then do an Import for the same affected map / layer with the exported file and republish the service.

After this we could confirm that the issue with the HTML TAG disappeared from the map service.

2022-08-29_11-51-29.png

Christian Brogaard Pedersen
Tags (2)
0 Kudos
David_Brooks
MVP Regular Contributor

@ChristianBPedersen this is a great workaround, which i've just tried to good effect. Next job is to get this working pythonically to loop through all datasets prior to publishing.


David
..Maps with no limits..
ChristianBPedersen
Occasional Contributor II

Glad to hear this is also working for you. We are also investigating a way to make this 'pythonically' in some way. Let's hope Esri might have a solution to this.

Christian Brogaard Pedersen
David_Brooks
MVP Regular Contributor

Here you go:

import arcpy, os
from arcpy import metadata as md
dataset = arcpy.GetParameterAsText(0)
   
src_item_md = md.Metadata(dataset)
outXML = r'C:\\Temp\Metadata.xml'
src_item_md.exportMetadata(outXML)
 
# Import the standard-format metadata content to the target item
if not src_item_md.isReadOnly:
    src_item_md.importMetadata(outXML)
    src_item_md.save()
arcpy.management.Delete(outXML)
arcpy.AddMessage("Finished.")

 


David
..Maps with no limits..