本文整理汇总了C#中System.Xml.XmlNodeReader类的典型用法代码示例。如果您正苦于以下问题:C# XmlNodeReader类的具体用法?C# XmlNodeReader怎么用?C# XmlNodeReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlNodeReader类属于System.Xml命名空间,在下文中一共展示了XmlNodeReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WMIBMySQL
public WMIBMySQL()
{
string file = Variables.ConfigurationDirectory + Path.DirectorySeparatorChar + "unwrittensql.xml";
Core.RecoverFile(file);
if (File.Exists(file))
{
Syslog.WarningLog("There is a mysql dump file from previous run containing mysql rows that were never successfuly inserted, trying to recover them");
XmlDocument document = new XmlDocument();
using (TextReader sr = new StreamReader(file))
{
document.Load(sr);
using (XmlNodeReader reader = new XmlNodeReader(document.DocumentElement))
{
XmlSerializer xs = new XmlSerializer(typeof(Unwritten));
Unwritten un = (Unwritten)xs.Deserialize(reader);
lock (unwritten.PendingRows)
{
unwritten.PendingRows.AddRange(un.PendingRows);
}
}
}
}
Thread reco = new Thread(Exec) {Name = "MySQL/Recovery"};
Core.ThreadManager.RegisterThread(reco);
reco.Start();
}
示例2: Create
public static EvaluationEngine Create(XmlDocument policyDoc, IXacmlPolicyRepository ch) {
Contract.Requires<ArgumentNullException>(policyDoc != null);
using (XmlReader reader = new XmlNodeReader(policyDoc.DocumentElement)) {
return EvaluationEngineFactory.Create(reader, ch);
}
}
示例3: RetargetWithMetadataConverter
/// <remarks>Internal for testing.</remarks>
internal static void RetargetWithMetadataConverter(XDocument xdoc, Version targetSchemaVersion, MetadataConverterDriver converter)
{
Debug.Assert(xdoc != null, "xdoc != null");
Debug.Assert(EntityFrameworkVersion.IsValidVersion(targetSchemaVersion), "invalid target schema version");
var inputXml = new XmlDocument { PreserveWhitespace = true };
using (var reader = xdoc.CreateReader())
{
inputXml.Load(reader);
}
var outputXml = converter.Convert(inputXml, targetSchemaVersion);
if (outputXml != null)
{
// Dev10 Bug 550594: There is a bug in XmlEditor that prevents from deleting the root node
// unless the root node has previous sibling (like a comment or Xml declaration).
if (xdoc.Root.PreviousNode == null)
{
xdoc.Root.AddBeforeSelf(new XComment(""));
}
// update xml document with new root element
xdoc.Root.Remove();
using (var reader = new XmlNodeReader(outputXml))
{
var newDoc = XDocument.Load(reader);
xdoc.Add(newDoc.Root);
}
// Do not reload artifact here
// Until the transaction is commited, the XLinq representation of the parsed xml tree hasn't been generated yet.
}
}
示例4: ReadConfig
private static CassandraSharpConfig ReadConfig(XmlDocument xmlDoc)
{
XmlSerializer xmlSer = new XmlSerializer(typeof(CassandraSharpConfig));
//MiniXmlSerializer xmlSer = new MiniXmlSerializer(typeof(CassandraSharpConfig));
using (XmlReader xmlReader = new XmlNodeReader(xmlDoc))
return (CassandraSharpConfig)xmlSer.Deserialize(xmlReader);
}
示例5: TransformNode
public static void TransformNode(XmlNode element, XmlReader xslTemplate)
{
XmlReader reader = new XmlNodeReader(element);
XmlReader transformResultReader = TransformXml(reader, xslTemplate, null);
element.CreateNavigator().ReplaceSelf(transformResultReader);
}
示例6: ToXDocument
/// <summary>
/// Converts XmlDocument to XDocument using load options.
/// </summary>
/// <param name="document">
/// The input document to be converted.
/// </param>
/// <param name="options">
/// The options for the conversion.
/// </param>
/// <returns>
/// Resulting XDocument.
/// </returns>
public static XDocument ToXDocument(this XmlDocument document, LoadOptions options)
{
using (XmlNodeReader reader = new XmlNodeReader(document))
{
return XDocument.Load(reader, options);
}
}
示例7: ToBackpackObject
// converts the given xml document to an object of the given type.
public static IBackpackObject ToBackpackObject(this XmlDocument xmlDocument, System.Type objType)
{
XmlNodeReader xmlNodeReader = new XmlNodeReader(xmlDocument.DocumentElement);
XmlSerializer xmlSerializer = new XmlSerializer(objType);
return (IBackpackObject)xmlSerializer.Deserialize(xmlNodeReader);
}
示例8: Read
public static void Read(XmlDocument xml)
{
List<DecModel> list = new List<DecModel>();
XNamespace ns = "HTTP://CLIS.HB_DEC";
using (var nodeReader = new XmlNodeReader(xml))
{
nodeReader.MoveToContent();
XDocument xdoc= XDocument.Load(nodeReader);
var seqNo = xdoc.Descendants(ns + "SEQ_NO").First().Value;
var entryId = xdoc.Descendants(ns + "ENTRY_ID").First().Value;
var ieFlag = xdoc.Descendants(ns + "I_E_FLAG").First().Value;
foreach (var element in xdoc.Descendants(ns + "HB_DEC_LIST"))
{
Console.WriteLine(element.Element(ns + "COP_G_NO").Value, element.Element(ns + "QTY").Value);
DecModel item = new DecModel();
item.EntryId = entryId;
item.SeqNo = seqNo;
item.IEFlag = ieFlag;
item.GNo = element.Element(ns + "COP_G_NO").Value;
item.Qty = Convert.ToDecimal(element.Element(ns + "QTY").Value);
list.Add(item);
}
if (list.Count > 0)
{
SqlHelper.Insert(list);
}
}
}
示例9: fillCountry
public static void fillCountry(ComboBox objCmbCountry,String CountryCode)
{
//DataTable objDT = new DataTable("Country");
//DataRow objRow;
//DataColumn objcol =new DataColumn("ContryName",typeof(System.String));
//objDT.Columns.Add(objcol);
//objcol =new DataColumn("ContryId",typeof(System.String));
//objDT.Columns.Add(objcol);
XmlNodeReader objXmlReader;
DataSet ds = new DataSet();
XmlDocument objOutXml = new XmlDocument();
String strInput = "<MS_LISTCOUNTRY_OUTPUT><COUNTRY COUNTRY_CODE='0' COUNTRY_NAME='Select one'/><COUNTRY COUNTRY_CODE='BD' COUNTRY_NAME='Bangladesh'/><COUNTRY COUNTRY_CODE='IN' COUNTRY_NAME='India' /><COUNTRY COUNTRY_CODE='NP' COUNTRY_NAME='Nepal' /> <COUNTRY COUNTRY_CODE='LK' COUNTRY_NAME='Srilanka' /><COUNTRY COUNTRY_CODE='BT' COUNTRY_NAME='Bhutan' /><COUNTRY COUNTRY_CODE='ML' COUNTRY_NAME='Maldives' /><COUNTRY COUNTRY_CODE='TB' COUNTRY_NAME='TBA' /> <Errors Status='False'><Error Code='' Description='' /></Errors></MS_LISTCOUNTRY_OUTPUT>";
objOutXml.LoadXml(strInput);
objXmlReader = new XmlNodeReader(objOutXml);
ds.ReadXml(objXmlReader);
objCmbCountry.DataSource = ds.Tables["COUNTRY"];
objCmbCountry.DisplayMember = "COUNTRY_NAME";
objCmbCountry.ValueMember = "COUNTRY_CODE";
objCmbCountry.SelectedIndex = 0;
if (CountryCode !="")
{
objCmbCountry.SelectedIndex = objCmbCountry.FindString("India");
}
}
示例10: Deserialise
private static Projects Deserialise(XmlDocument xmlDoc)
{
var nodeReader = new XmlNodeReader(xmlDoc);
nodeReader.ReadToDescendant("Projects");
var result = Serialiser.Deserialize(nodeReader);
return (Projects)result;
}
示例11: BindData
public void BindData()
{
#region 绑定轮换图片列表
DataGrid1.AllowCustomPaging = false;
DataGrid1.DataKeyField = "rotatepicid";
DataGrid1.TableHeaderName = "聚合轮换图片列表";
XmlDocumentExtender xmldocument = new XmlDocumentExtender();
xmldocument.Load(configPath);
XmlNode node = xmldocument.SelectSingleNode(targetNode);
if (node == null || node.ChildNodes.Count == 0)
{
DataGrid1.Visible = SaveRotatepic.Visible = false;
return;
}
XmlNodeReader rdr = new XmlNodeReader(node);
dsSrc.ReadXml(rdr);
dsSrc.Tables[0].Columns.Add("rowid");
int i = 0;
foreach (DataRow dr in dsSrc.Tables[0].Rows)
{
dr["rowid"] = i.ToString();
i++;
}
DataGrid1.DataSource = dsSrc.Tables[0];
DataGrid1.DataBind();
#endregion
}
示例12: Invoke
/// <summary>
/// Executes the command logics.
/// </summary>
public override void Invoke()
{
//print request xml
var doc = new XmlDocument();
var stringWriter = new StringWriter();
//get your document
try
{
doc.LoadXml(this.document.Text);
}
catch (Exception)
{
return;
}
//create reader and writer
var xmlReader = new XmlNodeReader(doc);
//set formatting options
var xmlWriter = new XmlTextWriter(stringWriter)
{
Formatting = Formatting.Indented,
Indentation = 3,
IndentChar = ' '
};
//write the document formatted
xmlWriter.WriteNode(xmlReader, true);
this.document.Text = stringWriter.ToString();
}
示例13: Create
public object Create(object parent, object configContext, XmlNode section)
{
ILog _log = null;
try
{
_log = LogManager.GetLogger(typeof(XmlConfigurator));
}
catch{}
object settings = null;
if (section == null)
return settings;
XmlSerializer xmlSerializer = new XmlSerializer(typeof(FluorineSettings));
XmlNodeReader reader = new XmlNodeReader(section);
try
{
settings = xmlSerializer.Deserialize(reader);
}
catch(Exception ex)
{
if( _log != null && _log.IsErrorEnabled )
_log.Error(ex.Message, ex);
}
finally
{
xmlSerializer = null;
}
return settings;
}
示例14: XmlPackage
/// <summary>
/// 从序列化的Xml文档中还原对象
/// </summary>
public XmlPackage(XmlDocument xmlDoc)
{
XmlNodeReader reader = new XmlNodeReader(xmlDoc.DocumentElement);
XmlSerializer ser = new XmlSerializer(typeof(XmlPackage));
XmlPackage pkg = (XmlPackage)ser.Deserialize(reader);
this.SetPackageDictionary(pkg.GetPackageDictionary());
}
示例15: Create
public object Create( object parent, object configContext, XmlNode section )
{
XPathNavigator navigator = section.CreateNavigator();
string typeName = ( string )navigator.Evaluate( "string(@type)" );
if( string.IsNullOrEmpty( typeName ) )
throw new ConfigurationErrorsException( string.Format( MISSING_TYPE_MSG, section.Name ), section );
Type type = Type.GetType( typeName );
if( type == null )
throw new ConfigurationErrorsException( string.Format( NULL_TYPE_MSG, typeName, section.Name ), section );
XmlSerializer serializer = new XmlSerializer( type );
XmlNodeReader reader = new XmlNodeReader( section );
try
{
return serializer.Deserialize( reader );
}
catch( Exception ex )
{
throw new ConfigurationErrorsException(
string.Format( FAILED_DESERIALIZE_MSG, typeName, section.Name, FormattedInnerExceptions( ex ) ),
ex, section );
}
}