本文整理汇总了C#中System.Xml.Linq.XDocument.IsXmlValid方法的典型用法代码示例。如果您正苦于以下问题:C# XDocument.IsXmlValid方法的具体用法?C# XDocument.IsXmlValid怎么用?C# XDocument.IsXmlValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Linq.XDocument
的用法示例。
在下文中一共展示了XDocument.IsXmlValid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
/// <summary>
/// Parses the settings configuration XML-document according to its version.
/// </summary>
/// <param name="document"></param>
/// <returns></returns>
internal static SettingsConfigurationFile Parse(XDocument document)
{
if (!document.IsXmlValid(Properties.Resources.SettingsSchema))
{
return null;
}
return ParseCore(document.Root);
}
示例2: ParseDisplayConfigAndAdd
private void ParseDisplayConfigAndAdd(XDocument doc, SettingsDisplayConfiguration config)
{
if (!doc.IsXmlValid(Properties.Resources.SettingsInfoSchema))
{
return;
}
foreach (XElement identifierE in doc.Root.Elements("Identifier"))
{
IdentifierInfo identifier = new IdentifierInfo();
identifier.Name = identifierE.Attribute("Name").Value;
identifier.DisplayText = identifierE.TryGetAttributeValue("DisplayText", identifier.Name);
identifier.Description = identifierE.TryGetAttributeValue("Description", null);
identifier.Order = identifierE.TryGetAttributeValue("Order", 0);
identifier.Parent = identifierE.TryGetAttributeValue("Parent", null);
foreach (XElement settingE in identifierE.Elements("Setting"))
{
SettingInfo setting = new SettingInfo();
setting.Identifier = identifier.Name;
setting.Name = settingE.Attribute("Name").Value;
setting.Category = settingE.TryGetAttributeValue("Category", null);
setting.DisplayText = settingE.TryGetAttributeValue("DisplayText", setting.Name);
setting.Description = settingE.TryGetAttributeValue("Description", null);
setting.Order = settingE.TryGetAttributeValue("Order", 0);
setting.Editor = settingE.TryGetAttributeValue("Editor", null);
setting.EditorParameter = settingE.TryGetAttributeValue("EditorParameter", null);
setting.IsDynamic = settingE.TryGetAttributeValue("IsDynamic", false);
identifier.Settings.Add(setting);
}
config.Identifiers.Add(identifier);
}
}