I have edited a lot of metadata externally. When I try to import the metadata, all line breaks are removed. As a test, I edited some metadata in the ArcGIS metadata editing environment, then exported it and then imported it. The import removed the line breaks. Is there a way around this?
No way around this... this is a feature of the XML parsers used by ArcGIS. Most XML parsers will remove extra whitespace within XML elements. This is because XML (like HTML) treats spaces and newlines as whitepace and does not preserve its formatting.
Thanks for your input Curtis. I have found a solution that works for me to preserve newlines when importing metadata via .xml file. If you follow the ArcGIS metadata standard, then the linebreaks are preserved. I guess this is because the import process is not translating the metadata from another format (e.g. FGDC) to the format ArcGIS stores it it (ArcGIS format).
In python, the tool and relevant parameter I used was:
arcpy.ImportMetadata_conversion ("C:\_WORK\myXML_metadata.xml, "FROM_ARCGIS", "C:\_WORK\Some.gdb\parcel)
Hope this helps someone else out.
Here is an example of the metadata I was able to import:
<metadata> <dataIdInfo> <idPurp>Here are some linebreaks. </idPurp> <!-- This corresponds to the "Summary" in the metadata, at least when viewed as FGDC metadata --> <themeKeys> <keyword>Parcel</keyword> <!-- Put lots of keywords if you like here. Not sure what the limit is. --> <keyword>Cadastre</keyword> <keyword>Perfect Topology</keyword> </themeKeys> <idAbs><DIV STYLE='text-align:Left;'><DIV><P><SPAN> <!-- the preceeding text in this idAbs tag was generated by ArcGIS in the xml data I copied out of the GDB_ITEMS table, "Documentation" field". It is not necessary, but suggests there may be room for even more sophisticated documentation in this idAbs tag. --> You can use html formatting tags by using the greater than and less than 'escape' character combinations to <b>spice</b> things up if you like. However, your description cannot begin with an escape character combination; it must be somewhere in the body of the text. (here is a line break). </SPAN></P></DIV></DIV> <!-- the preceeding text in this idAbs tag was generated by ArcGIS in the xml data I copied out of the GDB_ITEMS table, "Documentation" field". It is not necessary, I only included it in this example because it suggests there may be room for even more sophisticated documentation in this idAbs tag.--></idAbs> </dataIdInfo> <eainfo> <detailed> <attr> <attrlabl>PlanID</attrlabl> <!-- This has to match the name of a field you would like to describe --> <attrdef>The unique plan <u>identifier</u>. for linking to the (notice a line break here!) plan table.</attrdef> </attr> <attr> <attrlabl>ParcelClass </attrlabl> <attrdef>The Parcel Class ... One of: Upper, Lower</attrdef> </attr> </detailed> </eainfo> </metadata>