本文整理汇总了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();
}
}
示例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;
}