private GpxLink ReadGpxLink() { GpxLink link = new GpxLink(); string elementName = Reader_.Name; bool isEmptyElement = Reader_.IsEmptyElement; while (Reader_.MoveToNextAttribute()) { switch (Reader_.Name) { case "href": link.Href = Reader_.Value; break; } } if (isEmptyElement) { return(link); } while (Reader_.Read()) { switch (Reader_.NodeType) { case XmlNodeType.Element: switch (Reader_.Name) { case "text": link.Text = ReadContentAsString(); break; case "type": link.MimeType = ReadContentAsString(); break; default: SkipElement(); break; } break; case XmlNodeType.EndElement: if (Reader_.Name != elementName) { throw new FormatException(Reader_.Name); } return(link); } } throw new FormatException(elementName); }
private void WriteLink(string elementName, GpxLink link) { Writer_.WriteStartElement(elementName); Writer_.WriteAttributeString("href", link.Href); if (link.Text != null) { Writer_.WriteElementString("text", link.Text); } if (link.MimeType != null) { Writer_.WriteElementString("type", link.MimeType); } Writer_.WriteEndElement(); }