Exemple #1
0
        private GpxPerson ReadGpxPerson()
        {
            GpxPerson person = new GpxPerson();

            if (Reader_.IsEmptyElement)
            {
                return(person);
            }

            string elementName = Reader_.Name;

            while (Reader_.Read())
            {
                switch (Reader_.NodeType)
                {
                case XmlNodeType.Element:

                    switch (Reader_.Name)
                    {
                    case "name":
                        person.Name = ReadContentAsString();
                        break;

                    case "email":
                        person.Email = ReadGpxEmail();
                        break;

                    case "link":
                        person.Link = ReadGpxLink();
                        break;

                    default:
                        SkipElement();
                        break;
                    }

                    break;

                case XmlNodeType.EndElement:
                    if (Reader_.Name != elementName)
                    {
                        throw new FormatException(Reader_.Name);
                    }
                    return(person);
                }
            }

            throw new FormatException(elementName);
        }
Exemple #2
0
        private void WritePerson(string elementName, GpxPerson person)
        {
            Writer_.WriteStartElement(elementName);

            if (person.Name != null)
            {
                Writer_.WriteElementString("name", person.Name);
            }
            if (person.Email != null)
            {
                WriteEmail("email", person.Email);
            }

            Writer_.WriteEndElement();
        }