Example #1
0
        public static NoteTypeInfo[] ParseNoteTypesXml(string xml)
        {
            try
            {
                List <NoteTypeInfo> noteTypes = new List <NoteTypeInfo>();

                // get the root element
                XmlDocument document = new XmlDocument();
                document.LoadXml(xml);
                XmlElement noteTypesElement = document.SelectSingleNode(noteTypesTag) as XmlElement;

                XmlNodeList nodes = noteTypesElement.GetElementsByTagName(noteTypeTag);
                if ((nodes != null) && (nodes.Count > 0))
                {
                    foreach (XmlNode noteTypeNode in nodes)
                    {
                        XmlElement   noteTypeElement = noteTypeNode as XmlElement;
                        NoteTypeInfo noteType        = parseNoteType(noteTypeElement);
                        noteTypes.Add(noteType);
                    }
                }
                return(noteTypes.ToArray());
            }
            catch
            {
                return(null);
            }
        }
Example #2
0
        private static NoteTypeInfo parseNoteType(XmlElement noteTypeElement)
        {
            NoteTypeInfo noteType = new NoteTypeInfo();

            noteType.TypeID      = int.Parse(noteTypeElement.GetElementsByTagName(typeIDTag)[0].InnerText);
            noteType.Description = noteTypeElement.GetElementsByTagName(DescriptionTag)[0].InnerText;
            return(noteType);
        }
Example #3
0
        private static void writeNoteTypeXml(XmlTextWriter writer, NoteTypeInfo noteType)
        {
            writer.WriteStartElement(noteTypeTag);

            writer.WriteElementString(typeIDTag, noteType.TypeID.ToString());

            writer.WriteStartElement(DescriptionTag);
            writer.WriteCData(noteType.Description);
            writer.WriteEndElement();

            writer.WriteEndElement();
        }