# bundleToXML function

XMLNode bundleToXML(

1. OmemoBundle bundle

)

Converts an OmemoBundle `bundle` into its XML representation.

Returns the XML element.

## Implementation

    XMLNode bundleToXML(OmemoBundle bundle) {
      final prekeys = List<XMLNode>.empty(growable: true);
      for (final pk in bundle.opksEncoded.entries) {
        prekeys.add(
          XMLNode(
            tag: 'pk',
            attributes: <String, String>{
              'id': '${pk.key}',
            },
            text: pk.value,
          ),
        );
      }

      return XMLNode.xmlns(
        tag: 'bundle',
        xmlns: omemoXmlns,
        children: [
          XMLNode(
            tag: 'spk',
            attributes: <String, String>{
              'id': '${bundle.spkId}',
            },
            text: bundle.spkEncoded,
          ),
          XMLNode(
            tag: 'spks',
            text: bundle.spkSignatureEncoded,
          ),
          XMLNode(
            tag: 'ik',
            text: bundle.ikEncoded,
          ),
          XMLNode(
            tag: 'prekeys',
            children: prekeys,
          ),
        ],
      );
    }