private static XElement createEntry(BundleEntry entry, bool summary)
        {
            XElement result = null;

            if (entry is ResourceEntry)
            {
                ResourceEntry re = (ResourceEntry)entry;
                result = new XElement(BundleXmlParser.XATOMNS + BundleXmlParser.XATOM_ENTRY);

                if (!String.IsNullOrEmpty(re.Title))
                {
                    result.Add(xmlCreateTitle(re.Title));
                }
                if (Util.UriHasValue(entry.Id))
                {
                    result.Add(xmlCreateId(entry.Id));
                }

                if (re.LastUpdated != null)
                {
                    result.Add(new XElement(BundleXmlParser.XATOMNS + BundleXmlParser.XATOM_UPDATED, re.LastUpdated.Value));
                }
                if (re.Published != null)
                {
                    result.Add(new XElement(BundleXmlParser.XATOMNS + BundleXmlParser.XATOM_PUBLISHED, re.Published.Value));
                }

                if (!String.IsNullOrWhiteSpace(re.AuthorName))
                {
                    result.Add(xmlCreateAuthor(re.AuthorName, re.AuthorUri));
                }
            }
            else
            {
                result = new XElement(BundleXmlParser.XTOMBSTONE + BundleXmlParser.XATOM_DELETED_ENTRY);
                if (Util.UriHasValue(entry.Id))
                {
                    result.Add(new XAttribute(BundleXmlParser.XATOM_DELETED_REF, entry.Id.ToString()));
                }
                if (((DeletedEntry)entry).When != null)
                {
                    result.Add(new XAttribute(BundleXmlParser.XATOM_DELETED_WHEN, ((DeletedEntry)entry).When));
                }
            }

            if (entry.Links != null)
            {
                foreach (var l in entry.Links)
                {
                    if (l.Uri != null)
                    {
                        result.Add(xmlCreateLink(l.Rel, l.Uri));
                    }
                }
            }

            if (entry.Tags != null)
            {
                foreach (var tag in entry.Tags)
                {
                    result.Add(TagListSerializer.CreateTagCategoryPropertyXml(tag));
                }
            }

            if (entry is ResourceEntry)
            {
                ResourceEntry re = (ResourceEntry)entry;
                if (re.Resource != null)
                {
                    result.Add(new XElement(BundleXmlParser.XATOMNS + BundleXmlParser.XATOM_CONTENT,
                                            new XAttribute(BundleXmlParser.XATOM_CONTENT_TYPE, "text/xml"),
                                            FhirSerializer.SerializeResourceAsXElement(re.Resource, summary)));
                }

                // Note: this is a read-only property, so it is serialized but never parsed
                if (entry.Summary != null)
                {
                    result.Add(new XElement(BundleXmlParser.XATOMNS + BundleXmlParser.XATOM_SUMMARY,
                                            new XAttribute(BundleXmlParser.XATOM_CONTENT_TYPE, "xhtml"), XElement.Parse(entry.Summary)));
                }
            }

            return(result);
        }