当前位置: 首页>>代码示例>>C#>>正文


C# XPathDocument.GetAttribute方法代码示例

本文整理汇总了C#中System.Xml.XPath.XPathDocument.GetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# XPathDocument.GetAttribute方法的具体用法?C# XPathDocument.GetAttribute怎么用?C# XPathDocument.GetAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.XPath.XPathDocument的用法示例。


在下文中一共展示了XPathDocument.GetAttribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadFile

 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();
     }
 }
开发者ID:mehedi09,项目名称:GridWork,代码行数:33,代码来源:AnnotationPlugIn.cs

示例2: D900CdrDefinitionProvider

        private D900CdrDefinitionProvider(string xmlURI)
        {
            _schemaList = new List<D900CdrDefinitionSchema>();
            _defaultSchema = -1;
            _xmlVersion = String.Empty;

            bool def;

            #if FW35
            XElement cdrXML = XDocument
                .Load(xmlURI, LoadOptions.None)
                .Element("D900Cdr");

            __xmlVersion = cdrXML.Attribute("Version").Value;

            foreach (XElement schXML in cdrXML.Elements("Schema"))
            {
                D900CdrDefinitionSchema sch = new D900CdrDefinitionSchema(schXML.Attribute("Name").Value);
                ReadDefinitions(sch.Definitions, schXML, String.Empty);
                _schemaList.Add(sch);
                Boolean.TryParse(schXML.Attribute("Default").Value, out def);
                if (def) _defaultSchema = _schemaList.Count - 1;
            }
            #else
            XPathNavigator cdrXML = new XPathDocument(xmlURI)
                .CreateNavigator()
                .SelectSingleNode("D900Cdr");

            _xmlVersion = cdrXML.GetAttribute("Version", String.Empty);

            foreach (XPathNavigator schXML in cdrXML.Select("Schema"))
            {
                D900CdrDefinitionSchema sch = new D900CdrDefinitionSchema(schXML.GetAttribute("Name", String.Empty));
                ReadDefinitions(sch.Definitions, schXML, String.Empty);
                _schemaList.Add(sch);
                if (Boolean.TryParse(schXML.GetAttribute("Default", String.Empty), out def) && def)
                {
                    _defaultSchema = _schemaList.Count - 1;
                }
            }
            #endif
            if ((_defaultSchema < 0) && (_schemaList.Count > 0))
                _defaultSchema = 0;
            _currentSchema = _defaultSchema;
        }
开发者ID:neeraj9,项目名称:d900cdr-decoder,代码行数:45,代码来源:D900CdrDefinitionProvider.cs


注:本文中的System.Xml.XPath.XPathDocument.GetAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。