Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 46a1b3d6 authored by Harald MARTINI's avatar Harald MARTINI
Browse files

Added XmlHelper (from VECTO3GUI)

parent d2aa7f47
No related branches found
No related tags found
No related merge requests found
using System;
using System.Xml;
using Castle.Core.Internal;
namespace VECTO3GUI2020.Helper
{
public static class XmlHelper
{
public static XmlDocument ReadXmlDocument(string filePath)
{
if (filePath.IsNullOrEmpty())
return null;
var xmlDocument = new XmlDocument();
using (var reader = new XmlTextReader(filePath)) {
xmlDocument.Load(reader);
}
return xmlDocument;
}
public static XmlNodeList GetComponentNodes(XmlDocument xmlDocument, string parentNode, string nodeName)
{
if (xmlDocument == null || parentNode.IsNullOrEmpty() || nodeName.IsNullOrEmpty())
return null;
return xmlDocument.SelectNodes($"//*[local-name()='{parentNode}']//*[local-name()='{nodeName}']");
}
//public static bool ValidateXDocument(XDocument xDocument, Action<bool> resultAction = null,
// Action<XmlSeverityType, ValidationEvent> validationErrorAction = null)
//{
// var xmlDocument = xDocument.ToXmlDocument();
// if (xmlDocument == null)
// return false;
// var documentType = XMLHelper.GetDocumentType(xmlDocument.DocumentElement.LocalName);
// if (documentType == null)
// {
// throw new VectoException("unknown xml file! {0}", xmlDocument.DocumentElement.LocalName);
// }
// var validator = new XMLValidator(xmlDocument, resultAction, validationErrorAction);
// return validator.ValidateXML(documentType.Value); ;
//}
public static string GetXmlAbsoluteFilePath(string baseUri)
{
if (baseUri == null)
return null;
return Uri.UnescapeDataString(new Uri(baseUri).AbsolutePath);
}
}
}
......@@ -137,6 +137,7 @@
<Compile Include="Helper\DialogHelper.cs" />
<Compile Include="Helper\WindowHelper.cs" />
<Compile Include="Helper\XMLExtension.cs" />
<Compile Include="Helper\XmlHelper.cs" />
<Compile Include="Ninject\FactoryModule.cs" />
<Compile Include="Ninject\MultistageModule.cs" />
<Compile Include="Util\XML\Implementation\ComponentWriter\XMLPTOWriter.cs" />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment