Skip to content

Cannot find native way to add a custom attribute to the output xml nodes. #169

@kaiverge

Description

@kaiverge

ADAPT https://github.com/ADAPT/ISOv4Plugin

I need to add a custom attribute to the output xml nodes.

I cannot find any extensions/functions to add custom attribute to: ISOCustomer ISOFarm ISOPartField ISOGUidanceGroup

The way that works for me is to extend one of the base classes

public class ISOGuidanceGroupVG : ISOGuidanceGroup
   {
       public string GuidanceGroupType { get; set; }

       public override XmlWriter WriteXML(XmlWriter xmlBuilder)
       {
           xmlBuilder.WriteStartElement("GGP");
           xmlBuilder.WriteXmlAttribute("A", GuidanceGroupId);
           xmlBuilder.WriteXmlAttribute("B", GuidanceGroupDesignator);
           xmlBuilder.WriteXmlAttribute("CUSTOM_ATTRIBUTE", "value"); //adding custom attribute

![Uploading ZKiY0.png…]()
           if (XmlComments != null)
           {
               XmlComments.ForEach(delegate (string s)
               {
                   xmlBuilder.WriteComment(s);
               });
           }

           foreach (ISOGuidancePattern guidancePattern in GuidancePatterns)
           {
               guidancePattern.WriteXML(xmlBuilder);
           }

           foreach (ISOPolygon boundaryPolygon in BoundaryPolygons)
           {
               boundaryPolygon.WriteXML(xmlBuilder);
           }

           xmlBuilder.WriteEndElement();
           return xmlBuilder;
       }
   }

Now the question is, how do I do it in some native way...?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions