Select to view content in your preferred language

Simple metadata editor sample

2125
3
08-06-2010 02:01 AM
ThomasWaenke
Deactivated User
I need to automate some metadata editing tasks and used the 'simple metadata editor' sample as an example. In this example the following line updates the Title property.

propertySet.SetProperty("idinfo/citation/citeinfo/title", simpleEditorForm.Title);

With this method only one property/value can be written.
In my case I have some properties that allow multiple values like 2 email addresses under the same property name. How can I do this? I tried an object array as parameter but it did not work.

Thanks,
Thomas
0 Kudos
3 Replies
ThomasWaenke
Deactivated User
I changed my code and make use of the IXmlPropertySet Interface instead of IPropertySet

IMetadata metadata = (IMetadata)fc;
IPropertySet pset = metadata.Metadata;
IXmlPropertySet psetX = (IXmlPropertySet)metadata.Metadata;
string sValue = "myemail@company.com";

psetX.SetPropertyX("idinfo/ptcontac/cntinfo/cntemail", sValue,
              sriXmlPropertyType.esriXPTText,
              esriXmlSetPropertyAction.esriXSPAAddDuplicate, false);

metadata.Metadata = (IPropertySet)psetX;


This duplicates the email property in the metadata. But now another problem came up. The following snippet shows a part of the metadata

- <timeperd>
- <timeinfo>
- <mdattim>
- <sngdate>
  <caldate>09.2010</caldate>
  </sngdate>
- <sngdate>
  <caldate>10.2010</caldate>
  </sngdate>
  </mdattim>
  </timeinfo>
  <current>ground condition</current>
  </timeperd>

I need multiple <sngdate><caldate>xxxxxxx</caldate></sngdate> values.

With the method shown in my code and using the "idinfo/timeperd/timeinfo/mdattim/sngdate" property I can duplicate it, but the result are empty <sngdate></sngdate> nodes. When I duplicate the "idinfo/timeperd/timeinfo/mdattim/sngdate/caldate" property I get two <caldate> nodes between the <sngdate> parent nodes which is also wrong.

Is there a way to solve this with the SetPropertyX method?

Thanks,
Thomas
0 Kudos
JamesMacKay
Deactivated User
0 Kudos
ZeljkoVujaklija1
New Contributor
You probably solved your problem by now, but here is solution for someone else.

int counter = 0;
for (int counter=0; counter++; counter<10)
{
    xmlPropSet.SetPropertyX(""idinfo/timeperd/timeinfo/mdattim/sngdate", "", esriXmlPropertyType.esriXPTText, esriXmlSetPropertyAction.esriXSPAAddDuplicate, false);
    xmlPropSet.SetAttribute(String.Format(""idinfo/timeperd/timeinfo/mdattim/sngdate[{0}]/caldate", counter), "value", "<some date value>", esriXmlSetPropertyAction.esriXSPAAddOrReplace);
}
0 Kudos