Наследование: IXPathNavigable
Пример #1
5
        /// <summary>
        /// Processes the record.
        /// </summary>
        protected override void ProcessRecord()
        {
            this.WriteVerbose("Formatting log");
            using (var xmlReader = new StringReader(this.Log))
            {
                var xpath = new XPathDocument(xmlReader);
                using (var writer = new StringWriter())
                {
                    var transform = new XslCompiledTransform();
                    Func<string, string> selector = file => !Path.IsPathRooted(file) ? Path.Combine(Environment.CurrentDirectory, file) : file;
                    foreach (var fileToLoad in this.FormatFile.Select(selector))
                    {
                        this.WriteVerbose("Loading format file " + fileToLoad);
                        using (var stream = File.OpenRead(fileToLoad))
                        {
                            using (var reader = XmlReader.Create(stream))
                            {
                                transform.Load(reader);
                                transform.Transform(xpath, null, writer);
                            }
                        }
                    }

                    this.WriteObject(writer.GetStringBuilder().ToString(), false);
                }
            }
        }
Пример #2
0
		private ContentItem ReadDocument(XPathDocument xpd)
		{
			XPathNavigator navigator = xpd.CreateNavigator();
			OnMovingToRootItem(navigator);

			return OnReadingItem(navigator);
		}
Пример #3
0
        public string GetTweets()
        {
            // Uppgift 6:
            var twitter = new WebConsumer(TwitterConsumer.ServiceDescription, this.TokenManager);
            XPathDocument updates = new XPathDocument(TwitterConsumer.GetUpdates(twitter, this.AccessToken).CreateReader());
            XPathNavigator nav = updates.CreateNavigator();
            var parsedUpdates = from status in nav.Select("/statuses/status").OfType<XPathNavigator>()
                                where !status.SelectSingleNode("user/protected").ValueAsBoolean
                                select new
                                {
                                    User = status.SelectSingleNode("user/name").InnerXml,
                                    Status = status.SelectSingleNode("text").InnerXml,
                                };

            StringBuilder tableBuilder = new StringBuilder();
            tableBuilder.Append("<table><tr><td>Name</td><td>Update</td></tr>");

            foreach (var update in parsedUpdates)
            {
                tableBuilder.AppendFormat(
                    "<tr><td>{0}</td><td>{1}</td></tr>",
                    HttpUtility.HtmlEncode(update.User),
                    HttpUtility.HtmlEncode(update.Status));
            }
            tableBuilder.Append("</table>");
            return tableBuilder.ToString();
        }
Пример #4
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            var resourcefile = Server.MapPath(LocalResourceFile + ".ascx.resx");
            if (File.Exists(resourcefile))
            {
                var document = new XPathDocument(resourcefile);
                var navigator = document.CreateNavigator();

                var nodes = navigator.Select("/root/data[starts-with(@name, 'WhatsNew')]/@name");

                var releasenotes = new List<ReleaseInfo>();

                while (nodes.MoveNext())
                {
                    var key = nodes.Current.Value;
                    var version = string.Format(Localization.GetString("notestitle.text", LocalResourceFile), key.Replace("WhatsNew.", string.Empty));
                    releasenotes.Add(new ReleaseInfo(Localization.GetString(key, LocalResourceFile), version));
                }

                releasenotes.Sort(CompareReleaseInfo);

                WhatsNewList.DataSource = releasenotes;
                WhatsNewList.DataBind();

                header.InnerHtml = Localization.GetString("header.text", LocalResourceFile);
                footer.InnerHtml = Localization.GetString("footer.text", LocalResourceFile);
            }
        }
Пример #5
0
		public override void PopulateTree (Tree tree)
		{
			XPathNavigator n = new XPathDocument (Path.Combine (basedir, "toc.xml")).CreateNavigator ();
			n.MoveToRoot ();
			n.MoveToFirstChild ();
			PopulateNode (n.SelectChildren ("node", ""), tree.RootNode);
		}
Пример #6
0
        public static string Transform(string xml, string xslPath)
        {
            try
            {
                //create an XPathDocument using the reader containing the XML
                MemoryStream m = new MemoryStream(System.Text.Encoding.Default.GetBytes(xml));

                XPathDocument xpathDoc = new XPathDocument(new StreamReader(m));

                //Create the new transform object
                XslCompiledTransform transform = new XslCompiledTransform();

                //String to store the resulting transformed XML
                StringBuilder resultString = new StringBuilder();

                XmlWriter writer = XmlWriter.Create(resultString);

                transform.Load(xslPath);

                transform.Transform(xpathDoc,writer);
               
                return resultString.ToString();
            }
            catch (Exception e)
            {

                Console.WriteLine("Exception: {0}", e.ToString());
                return e.ToString();
            }
        }
Пример #7
0
        private static StringBuilder Transform(string gcmlPath)
        {
            if(!File.Exists(gcmlPath))
            {
                throw new GCMLFileNotFoundException("The GCML File" + gcmlPath + " does not exist.");
            }

            if(!File.Exists(xsltFilePath))
            {
                throw new XSLTFileNotFoundException("The XSLT File" + xsltFilePath + " does not exist.");
            }

            StringBuilder sb = new StringBuilder();
            XmlTextReader xmlSource = new XmlTextReader(gcmlPath);
            XPathDocument xpathDoc = new XPathDocument(xmlSource);
            XslCompiledTransform xsltDoc = new XslCompiledTransform();

            xsltDoc.Load(xsltFilePath);

            StringWriter sw = new StringWriter(sb);
            try
            {
                xsltDoc.Transform(xpathDoc, null, sw);
            }
            catch (XsltException except)
            {
                Console.WriteLine(except.Message);
                throw except;
            }

            return sb;
        }
Пример #8
0
        /// <inheritdoc />
        public override XPathNavigator this[string key]
        {
            get
            {
                string xml;

                // Try the in-memory cache first
                XPathNavigator content = base[key];

                // If not found there, try the database caches if there are any
                if(content == null && esentCaches.Count != 0)
                    foreach(var c in esentCaches)
                        if(c.TryGetValue(key, out xml))
                        {
                            // Convert the XML to an XPath navigator
                            using(StringReader textReader = new StringReader(xml))
                                using(XmlReader reader = XmlReader.Create(textReader, settings))
                                {
                                    XPathDocument document = new XPathDocument(reader);
                                    content = document.CreateNavigator();
                                }
                        }

                return content;
            }
        }
Пример #9
0
        public KeyboardLayoutType GetKeyboardLayoutType(string locale)
        {
            if (String.IsNullOrEmpty(locale))
                return KeyboardLayoutType.US;

            // Get the layout type - US, European etc. The locale in the XML file must be upper case!
            string expression = @"/keyboards/keyboard[locale='" + locale.ToUpper(CultureInfo.InvariantCulture) + "']";

            XPathNodeIterator iterator;

            using (Stream xmlstream = GetXMLDocumentAsStream(_keyboardfilename))
            {
                XPathDocument document = new XPathDocument(xmlstream);
                XPathNavigator nav = document.CreateNavigator();

                iterator = nav.Select(expression);
            }

            int value = 0; // Default to US 

            if (iterator.Count == 1)
            {
                iterator.MoveNext();
                string layout = GetElementValue("layout", iterator.Current);
                if (String.IsNullOrEmpty(layout) == false)
                {
                    value = Int32.Parse(layout, CultureInfo.InvariantCulture.NumberFormat);
                }
            }

            return (KeyboardLayoutType)value;
        }
Пример #10
0
        public void RunXslt(String xsltFile, String xmlDataFile, String outputXml)
        {
            XPathDocument input = new XPathDocument(xmlDataFile);

            XslTransform myXslTrans = new XslTransform() ;
            XmlTextWriter output = null;
            try
            {
                myXslTrans.Load(xsltFile);

                output = new XmlTextWriter(outputXml, null);
                output.Formatting = Formatting.Indented;

                myXslTrans.Transform(input, null, output);

            }
            catch (Exception e)
            {
                String msg = e.Message;
                if (msg.IndexOf("InnerException") >0)
                {
                    msg = e.InnerException.Message;
                }

                MessageBox.Show("Error: " + msg + "\n" + e.StackTrace, "Xslt Error File: " + xsltFile, MessageBoxButtons.OK, MessageBoxIcon.Error);

            }
            finally
            {
                try { output.Close(); }
                catch (Exception) { }
            }
        }
Пример #11
0
 /// <summary>
 /// Read and apply persistent form display data (Size, Position, and WindowState)
 /// </summary>
 /// <param name="form">Form to be set</param>
 internal static void ReadPersistentFormData(System.Windows.Forms.Form form)
 {
     try {
         StreamReader reader = new StreamReader(Application.ExecutablePath + ".formdata.xml", Encoding.UTF8);
         XPathDocument doc = new XPathDocument(reader);
         XPathNavigator nav = doc.CreateNavigator();
         try {
             XPathNodeIterator iterator = nav.Select(String.Format("//Forms/{0}/PersistentData", form.Name));
             iterator.MoveNext();
             form.WindowState = (FormWindowState)Enum.Parse(form.WindowState.GetType(), iterator.Current.GetAttribute("WindowState",	""), false);
             if (form.WindowState == FormWindowState.Normal) {
                 form.Top	= Convert.ToInt16(iterator.Current.GetAttribute("Top",		"").ToString());
                 form.Left	= Convert.ToInt16(iterator.Current.GetAttribute("Left",		"").ToString());
                 form.Width	= Convert.ToInt16(iterator.Current.GetAttribute("Width",	"").ToString());
                 form.Height	= Convert.ToInt16(iterator.Current.GetAttribute("Height",	"").ToString());
             }
         }
         catch {
         }
         finally {
             reader.Close();
         }
     }
     catch {
     }
 }
Пример #12
0
 public override void LoadFile(Stream stream)
 {
     string p = AnnotationPlugIn.GenerateDataRecordPath();
     // t|1|OrderDetails,_Annotation_Attachment20091219164153Z|10248|11
     Match m = Regex.Match(this.Value, "_Annotation_Attachment(\\w+)\\|");
     string fileName = Path.Combine(p, (m.Groups[1].Value + ".xml"));
     XPathNavigator nav = new XPathDocument(fileName).CreateNavigator().SelectSingleNode("/*");
     fileName = Path.Combine(p, ((Path.GetFileNameWithoutExtension(fileName) + "_")
                     + Path.GetExtension(nav.GetAttribute("fileName", String.Empty))));
     if (!(this.Value.StartsWith("t|")))
     {
         this.ContentType = nav.GetAttribute("contentLength", String.Empty);
         HttpContext.Current.Response.ContentType = this.ContentType;
     }
     this.FileName = nav.GetAttribute("fileName", String.Empty);
     Stream input = File.OpenRead(fileName);
     try
     {
         byte[] buffer = new byte[(1024 * 64)];
         long offset = 0;
         long bytesRead = input.Read(buffer, 0, buffer.Length);
         while (bytesRead > 0)
         {
             stream.Write(buffer, 0, Convert.ToInt32(bytesRead));
             offset = (offset + bytesRead);
             bytesRead = input.Read(buffer, 0, buffer.Length);
         }
     }
     finally
     {
         input.Close();
     }
 }
Пример #13
0
        static XPathUtils()
        {
            XmlDocument doc = new XmlDocument();
              doc.AppendChild(doc.CreateElement("DocumentRoot"));

              _emptyXPathDocument = new XPathDocument(new XmlNodeReader(doc));
        }
Пример #14
0
        /// <summary>
        /// Returns the line number and line position of the specified XML node.
        /// </summary>
        /// <param name="xmlFileFullPathName">The fully qualified path name to the XML file.</param>
        /// <param name="xpath">The XPath of the XML node to get the location of.</param>
        /// <param name="lineNumber">If the return value is true, the line number of the specified XML element.</param>
        /// <param name="linePosition">If the return value is true, the posiiton on the line of the specified XML element.</param>
        /// <returns>True if the element is found, otherwise false.</returns>
        public static bool GetTextLocationOfXmlNode(string xmlFileFullPathName, string xpath, out int lineNumber, out int linePosition)
        {
            bool isElementFound;
            XPathDocument xpathSlashDoc = new XPathDocument(xmlFileFullPathName);
            XPathNavigator navSlashDoc = xpathSlashDoc.CreateNavigator();
            XPathNodeIterator itr = navSlashDoc.Select(xpath);
            if (itr.Count > 0 && itr.MoveNext())
            {
                IXmlLineInfo lineInfo = itr.Current as IXmlLineInfo;
                DiagnosticService.Assert(lineInfo != null, "Line Information not available.");

                if (lineInfo != null)
                {
                    lineNumber = lineInfo.LineNumber;
                    linePosition = lineInfo.LinePosition;
                }
                else
                {
                    lineNumber = -1;
                    linePosition = -1;
                }
                Debug.WriteLine(itr.Current.Name + "(" + lineNumber + ","+ linePosition +")");
                isElementFound = true;
            }
            else
            {
                lineNumber = -1;
                linePosition = -1;
                isElementFound = false;
            }
            return isElementFound;
        }
Пример #15
0
        public Episode(FileInfo file, Season seasonparent)
            : base(file.Directory)
        {
            String xmlpath = file.Directory.FullName + "/metadata/" + Path.GetFileNameWithoutExtension(file.FullName) + ".xml";
            if (!File.Exists(xmlpath))
            {
                Valid = false;
                return;
            }
            EpisodeXml = new XPathDocument(xmlpath);
            EpisodeNav = EpisodeXml.CreateNavigator();
            EpisodeFile = file;

            _season = seasonparent;

            transX = 200;
            transY = 100;

            backdropImage = _season.backdropImage;

            XPathNodeIterator nodes = EpisodeNav.Select("//EpisodeID");
            nodes.MoveNext();
            folderImage = file.Directory.FullName + "/metadata/" + nodes.Current.Value + ".jpg";

            if (!File.Exists(folderImage))
                folderImage = "/Images/nothumb.jpg";
            title = this.asTitle();

            videoURL = EpisodeFile.FullName;

            LoadImage(folderImage);
        }
Пример #16
0
        /// <summary>
        /// Tries to extract the BluRay title.
        /// </summary>
        /// <returns></returns>
        public string GetTitle()
        {
            string metaFilePath = Path.Combine(DirectoryBDMV.FullName, @"META\DL\bdmt_eng.xml");
              if (!File.Exists(metaFilePath))
            return null;

              try
              {
            XPathDocument metaXML = new XPathDocument(metaFilePath);
            XPathNavigator navigator = metaXML.CreateNavigator();
            if (navigator.NameTable != null)
            {
              XmlNamespaceManager ns = new XmlNamespaceManager(navigator.NameTable);
              ns.AddNamespace("", "urn:BDA:bdmv;disclib");
              ns.AddNamespace("di", "urn:BDA:bdmv;discinfo");
              navigator.MoveToFirst();
              XPathNavigator node = navigator.SelectSingleNode("//di:discinfo/di:title/di:name", ns);
              if (node != null)
            return node.ToString().Trim();
            }
              }
              catch (Exception e)
              {
            ServiceRegistration.Get<ILogger>().Error("BDMEx: Meta File Error: ", e);
              }
              return null;
        }
Пример #17
0
		public String GetDetail(String name, String log, DetailEnum detail)
		{
			String xsl = null;

			if (detail == DetailEnum.Summary)
			{
				return GetSummary(name, log);
			}
			else if (detail == DetailEnum.Compilation)
			{
				xsl = GetXslFullFileName("compile.xsl");
			}
			else if (detail == DetailEnum.Modifications)
			{
				xsl = GetXslFullFileName("modifications.xsl");
			}
			else if (detail == DetailEnum.UnitTestsDetail)
			{
				xsl = GetXslFullFileName("unittests.xsl");
			}
			else if (detail == DetailEnum.UnitTestsSummary)
			{
				xsl = GetXslFullFileName("AlternativeNUnitDetails.xsl");
			}

			String content = cruiseManager.GetLog(name, log);

			XPathDocument document = new XPathDocument(new StringReader(content));

			return logTransformer.Transform(document, xsl);
		}
		private void AddTargets (string map, string input, string baseOutputPath, XPathExpression outputXPath, string link, XPathExpression formatXPath, XPathExpression relativeToXPath) {

			XPathDocument document = new XPathDocument(map);

			XPathNodeIterator items = document.CreateNavigator().Select("/*/item");
			foreach (XPathNavigator item in items) {

				string id = (string) item.Evaluate(artIdExpression);
				string file = (string) item.Evaluate(artFileExpression);
				string text = (string) item.Evaluate(artTextExpression);

				id = id.ToLower();
				string name = Path.GetFileName(file);

				ArtTarget target = new ArtTarget();
				target.Id = id;
				target.InputPath = Path.Combine(input, file);
				target.baseOutputPath = baseOutputPath;
                target.OutputXPath = outputXPath;
                
                if (string.IsNullOrEmpty(name)) target.LinkPath = link;
                else target.LinkPath = string.Format("{0}/{1}", link, name);
                
				target.Text = text;
                target.Name = name;
                target.FormatXPath = formatXPath;
                target.RelativeToXPath = relativeToXPath;

				targets[id] = target;
				// targets.Add(id, target);
            }

	    }
Пример #19
0
        static int Main(string[] args)
        {
            Console.WriteLine("XMLTo v0.1 [www.mosa-project.org]");
            Console.WriteLine("Copyright 2009 by the MOSA Project. Licensed under the New BSD License.");
            Console.WriteLine("Written by Philipp Garcia ([email protected])");
            Console.WriteLine();
            Console.WriteLine("Usage: XMLTo <xml file> <xsl file> <output file>");
            Console.WriteLine();

            if (args.Length < 3)
             {
                Console.Error.WriteLine("ERROR: Missing arguments");
                return -1;
            }

            try {
                XPathDocument myXPathDoc = new XPathDocument(args[0]);
                XslCompiledTransform myXslTrans = new XslCompiledTransform();
                myXslTrans.Load(args[1]);
                XmlTextWriter myWriter = new XmlTextWriter(args[2], null);
                myXslTrans.Transform(myXPathDoc, null, myWriter);

                return 0;
            }
            catch (Exception e) {
                Console.Error.WriteLine("Exception: {0}", e.ToString());
                return -1;
            }
        }
Пример #20
0
 static AutoUpdateHepler()
 {
     string str = FileUtility.ApplicationRootPath + @"\update";
     if (LoggingService.IsInfoEnabled)
     {
         LoggingService.Info("读取升级配置:" + str);
     }
     XmlConfigSource source = null;
     if (System.IO.File.Exists(str + ".cxml"))
     {
         XmlTextReader decryptXmlReader = new CryptoHelper(CryptoTypes.encTypeDES).GetDecryptXmlReader(str + ".cxml");
         IXPathNavigable document = new XPathDocument(decryptXmlReader);
         source = new XmlConfigSource(document);
         decryptXmlReader.Close();
     }
     else if (System.IO.File.Exists(str + ".xml"))
     {
         source = new XmlConfigSource(str + ".xml");
     }
     if (source != null)
     {
         softName = source.Configs["FtpSetting"].GetString("SoftName", string.Empty);
         version = source.Configs["FtpSetting"].GetString("Version", string.Empty);
         server = source.Configs["FtpSetting"].GetString("Server", string.Empty);
         user = source.Configs["FtpSetting"].GetString("User", string.Empty);
         password = source.Configs["FtpSetting"].GetString("Password", string.Empty);
         path = source.Configs["FtpSetting"].GetString("Path", string.Empty);
         liveup = source.Configs["FtpSetting"].GetString("LiveUp", string.Empty);
         autoupdate = source.Configs["FtpSetting"].GetString("autoupdate", string.Empty);
     }
 }
 public ResinConf(String file)
 {
   _xPathDoc = new XPathDocument(file);
   _docNavigator = _xPathDoc.CreateNavigator();
   _xmlnsMgr = new XmlNamespaceManager(_docNavigator.NameTable);
   _xmlnsMgr.AddNamespace("caucho", "http://caucho.com/ns/resin");
 }
        public void QueryAndNamespace()
        {
            try
            {
                var output = "";
                var path = Server.MapPath("~/App_Data/bookstore.xml");
                XPathDocument document = new XPathDocument(path);
                XPathNavigator navigator = document.CreateNavigator();
                XPathExpression query = navigator.Compile("/bookstore:bookstore/bookstore:book");
                XmlNamespaceManager manager = new XmlNamespaceManager(navigator.NameTable);
                manager.AddNamespace("bookstore", "urn:newbooks-schema");
                query.SetContext(manager);
                XPathNodeIterator nodes = navigator.Select(query);

                while (nodes.MoveNext())
                {
                    output += nodes.Current.OuterXml;
                }

                Textarea4.InnerHtml = output;
            }
            catch (Exception ex)
            {
                Textarea4.InnerHtml = ex.Message;
            }
        }
Пример #23
0
		void LoadFile(string filepath) {
			var xml = new XPathDocument(filepath).CreateNavigator();
			ProjectPath = Val(xml, "/Settings/ProjectPath");
			PropertyFilepath = Val(xml, "/Settings/PropertyFilepath");
			LesseeFilepath = Val(xml, "/Settings/LesseeFilepath");
			AutoSave = Boolean.Parse(Val(xml, "/Settings/AutoSave"));
		}
Пример #24
0
 public EnumCollection Process(EnumCollection enums)
 {
     var nav = new XPathDocument(Overrides).CreateNavigator();
     enums = ProcessNames(enums, nav);
     enums = ProcessConstants(enums, nav);
     return enums;
 }
Пример #25
0
        public bool CancelAppointment(HackExchangeContext context, CalendarItem appointment)
        {
            var url = context.Endpoint;
            var request = new HttpRequestMessage(HttpMethod.Post, url);
            var postBodyTemplate = LoadXml("CancelAppointment");
            var postBody = string.Format(postBodyTemplate, appointment.Id, appointment.ChangeKey);
            request.Content = new StringContent(postBody, Encoding.UTF8, "text/xml");

            var clientHandler = new HttpClientHandler()
            {
                Credentials = context.Credentials
            };
            using (var client = new HttpClient(clientHandler))
            {
                var response = client.SendAsync(request).Result;
                var responseBody = response.Content.ReadAsStringAsync().Result;

                var doc = new XPathDocument(new StringReader(responseBody));
                var nav = doc.CreateNavigator();
                var nsManager = new XmlNamespaceManager(nav.NameTable);
                nsManager.AddNamespace("m", "http://schemas.microsoft.com/exchange/services/2006/messages");
                nsManager.AddNamespace("t", "http://schemas.microsoft.com/exchange/services/2006/types");

                var responseClass = EvaluateXPath(nav, nsManager, "//m:DeleteItemResponseMessage/@ResponseClass");
                return responseClass == "Success";
            }
        }
Пример #26
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// This Constructor creates a new PackageInstaller instance
        /// </summary>
        /// <param name="package">A PackageInfo instance</param>
        /// <history>
        /// 	[cnurse]	01/21/2008  created
        /// </history>
        /// -----------------------------------------------------------------------------
        public PackageInstaller(PackageInfo package)
        {
            IsValid = true;
            DeleteFiles = Null.NullBoolean;
            Package = package;
            if (!string.IsNullOrEmpty(package.Manifest))
            {
				//Create an XPathDocument from the Xml
                var doc = new XPathDocument(new StringReader(package.Manifest));
                XPathNavigator nav = doc.CreateNavigator().SelectSingleNode("package");
                ReadComponents(nav);
            }
            else
            {
                ComponentInstallerBase installer = InstallerFactory.GetInstaller(package.PackageType);
                if (installer != null)
                {
					//Set package
                    installer.Package = package;

                    //Set type
                    installer.Type = package.PackageType;
                    _componentInstallers.Add(0, installer);
                }
            }
        }
Пример #27
0
        public void Apply (XmlDocument targetDocument, IXmlNamespaceResolver context) {

            XPathExpression local_file_expression = file_expression.Clone();
            local_file_expression.SetContext(context);

            XPathExpression local_source_expression = source_expression.Clone();
            local_source_expression.SetContext(context);

            XPathExpression local_target_expression = target_expression.Clone();
            local_target_expression.SetContext(context);

            string file_name = (string) targetDocument.CreateNavigator().Evaluate(local_file_expression);
            string file_path = Path.Combine(root_directory, file_name);

            if (!File.Exists(file_path)) return;
            XPathDocument sourceDocument = new XPathDocument(file_path);

            XPathNavigator target_node = targetDocument.CreateNavigator().SelectSingleNode(local_target_expression);
            if (target_node == null) return;

            XPathNodeIterator source_nodes = sourceDocument.CreateNavigator().Select(local_source_expression);
            foreach (XPathNavigator source_node in source_nodes) {
                target_node.AppendChild(source_node);
            }
       
        }
Пример #28
0
        public bool GenerateReport(string fileName)
        {
            bool retCode = false;
            ResetReportViwer();

            XslCompiledTransform xslt = new XslCompiledTransform();
            xslt.Load(rptXslPath);

            if ( File.Exists(fileName) == true)
            {
                XPathDocument myXPathDoc = new XPathDocument(fileName);
                StringWriter sw = new StringWriter();
                XmlWriter xmlWriter = new XmlTextWriter(sw);

                // using makes sure that we flush the writer at the end
                xslt.Transform(myXPathDoc, null, xmlWriter);
                xmlWriter.Flush();
                xmlWriter.Close();

                string xml = sw.ToString();

                HtmlDocument htmlDoc = axBrowser.Document;
                htmlDoc.Write(xml);
                retCode = true;
            }
            else
            {

                retCode = false;
            }

            return retCode;
        }
        public HttpResponseMessage Get(string id)
        {
            try
            {
                TrataRetorno objRetorno = new TrataRetorno();
                List<Indice> Indices = new List<Indice>();
                string urlInicial = "http://finance.yahoo.com/webservice/v1/symbols/";
                string urlFinal = "/quote?format=xml&view=detail";
                string[] stringSeparators = new string[] { "," };
                string[] result;

                result = id.Split(stringSeparators, StringSplitOptions.None);
                foreach (string s in result)
                {
                    XPathDocument doc = new XPathDocument(urlInicial + s + urlFinal);
                    Indices.Add(objRetorno.TratarRetorno(doc));
                }

                return Request.CreateResponse(HttpStatusCode.OK, Indices); ;
            }
            catch (KeyNotFoundException)
            {
                string mensagem = string.Format("Não foi possível criptografar a entrada: ", id);
                HttpError error = new HttpError(mensagem);
                return Request.CreateResponse(HttpStatusCode.NotFound, error);
            }
        }
Пример #30
0
        static void Main(string[] args)
        {
            if (args.Length != 2 || args.Any(p => p == "/?" || p == "-?")) {
            ShowHelp();
             }

             try {
            var doc = new XPathDocument(args[0]);
            XPathNavigator nav = doc.CreateNavigator();

            var o = nav.Evaluate(args[1]);
            if (o is XPathNodeIterator) {
               var iter = o as XPathNodeIterator;
               while (iter.MoveNext()) {
                  Console.WriteLine(iter.Current.Value);
               }
            }
            else {
               Console.WriteLine(o);
            }
             }
             catch (Exception ex) {
            Console.WriteLine(ex);
            Environment.Exit(1);
             }
        }