本文整理汇总了C#中System.Web.UI.WebControls.XmlDataSource.GetXmlDocument方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDataSource.GetXmlDocument方法的具体用法?C# XmlDataSource.GetXmlDocument怎么用?C# XmlDataSource.GetXmlDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.XmlDataSource
的用法示例。
在下文中一共展示了XmlDataSource.GetXmlDocument方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: datafile
public static void datafile (Page p)
{
string originalxml = @"<?xml version=""1.0"" encoding=""utf-8""?><bookstore xmlns:bk=""urn:samples""><book genre=""novel"" publicationdate=""1999"" bk:ISBN=""0192100262""><title>Pride and Prejudice</title><author><first-name>Jane</first-name><last-name>Austen</last-name></author><price>24.95</price>""
</book><book genre=""novel"" publicationdate=""1985"" bk:ISBN=""0771008139""><title>The Handmaid's Tale</title><author><first-name>Margaret</first-name><last-name>Atwood</last-name></author><price>29.95</price></book></bookstore>";
XmlDataSource ds = new XmlDataSource ();
p.Form.Controls.Add (ds);
ds.DataFile = "~/XMLDataSourceTest.xml";
ds.DataBind ();
string derivedxml = ((XmlDocument) ds.GetXmlDocument ()).InnerXml;
HtmlDiff.AssertAreEqual (originalxml, derivedxml, "Loading xml");
}
示例2: GetCaption
/// <summary>
/// Returns captions or text for various languages.
/// </summary>
/// <param name="nodeName">Node name.</param>
/// <param name="items">Items to add formatted to positions in string.</param>
/// <returns>Text from XML file.</returns>
public static string GetCaption(string nodeName, params string[] items)
{
string retval = "";
XmlDataSource xmlnd = new XmlDataSource();
xmlnd.ID = "LanguageFileXML";
xmlnd.EnableCaching = true;
xmlnd.CacheDuration = 900;
xmlnd.CacheExpirationPolicy = System.Web.UI.DataSourceCacheExpiry.Sliding;
xmlnd.DataFile = HttpContext.Current.Server.MapPath(Configuration.DefaultTextXML);
try
{
retval = xmlnd.GetXmlDocument().ChildNodes.Item(1).SelectSingleNode(nodeName).InnerText;
}
catch (Exception exc)
{
throw new Exception("Node " + nodeName + " not found in " + Configuration.DefaultTextXML + ".", exc);
}
finally
{
xmlnd = null;
}
if (items != null)
{
retval = string.Format(retval, items);
}
return retval;
}
示例3: GetXmlDataSourceData
private AdRec[] GetXmlDataSourceData(XmlDataSource xmlDataSource)
{
XmlDocument xmlDocument = xmlDataSource.GetXmlDocument();
if (xmlDocument == null)
{
return null;
}
return this.LoadXmlDocument(xmlDocument);
}
示例4: GetXmlDataSourceData
private AdRec [] GetXmlDataSourceData(XmlDataSource xmlDataSource) {
Debug.Assert(xmlDataSource != null);
XmlDocument doc = xmlDataSource.GetXmlDocument();
if (doc == null) {
return null;
}
return LoadXmlDocument(doc);
}