コード例 #1
0
ファイル: PoiXmlAdapter.cs プロジェクト: misiek/foo
        public override object parse(XmlNode objNode)
        {
            // get required poi's parameters
            string name = objNode.SelectSingleNode("name").InnerText.Trim();
            double latitude = Convert.ToDouble(objNode.SelectSingleNode("latitude").InnerText.Trim());
            double longitude = Convert.ToDouble(objNode.SelectSingleNode("longitude").InnerText.Trim());
            string lang = objNode.SelectSingleNode("lang").InnerText.Trim();
            string type = objNode.SelectSingleNode("type").InnerText.Trim();
            string descr = objNode.SelectSingleNode("descr").InnerText.Trim();
            // instantiate poi
            Poi poi = new Poi(name, latitude, longitude, lang, type, descr);
            // parse media files

            MediaFilesXmlAdapter mediaFilesParser = new MediaFilesXmlAdapter(poi.getMediaFiles());
            XmlNode mediaFilesNode = objNode.SelectSingleNode(mediaFilesParser.getXmlNodeName());
            mediaFilesParser.parse(mediaFilesNode);

            MainDetailsXmlAdapter mainDetailsParser = new MainDetailsXmlAdapter(poi.getMainDetails());
            XmlNode mainDetailsNode = objNode.SelectSingleNode(mainDetailsParser.getXmlNodeName());
            mainDetailsParser.parse(mainDetailsNode);

            return poi;
        }
コード例 #2
0
ファイル: PoiMapperHdd.cs プロジェクト: misiek/foo
 /**
  * Loads Poi media data: media files and main details.
  */
 public void loadMedia(Poi poi, string poiSubDir)
 {
     //Debug.WriteLine("loadMedia: poi sub dir: " + poiSubDir, ToString());
     // load xml document
     XmlDocument poiXmlDoc = new XmlDocument();
     string poiXmlPath = getPoiXmlPath(poiSubDir);
     poiXmlDoc.Load(poiXmlPath);
     // get media files
     XmlNode mediaFilesNode = poiXmlDoc.SelectSingleNode("/poi/media_files");
     if (mediaFilesNode != null)
     {
         MediaFilesXmlAdapter mfxa = new MediaFilesXmlAdapter(poi.getMediaFiles());
         mfxa.parse(mediaFilesNode);
     }
     // get main details
     XmlNode mainDetailsNode = poiXmlDoc.SelectSingleNode("/poi/details");
     if (mainDetailsNode != null)
     {
         MainDetailsXmlAdapter mdxa = new MainDetailsXmlAdapter(poi.getMainDetails());
         mdxa.parse(mainDetailsNode);
     }
     string poiMediaFilesPath = getPoiMediaFilesPath(poiSubDir);
     if (poiMediaFilesPath != null)
     {
         loadMediaFiles(poi.getAllMediaFiles(), poiMediaFilesPath);
     }
 }