本文整理汇总了C#中XmlNode类的典型用法代码示例。如果您正苦于以下问题:C# XmlNode类的具体用法?C# XmlNode怎么用?C# XmlNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlNode类属于命名空间,在下文中一共展示了XmlNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunFileAction
private static bool RunFileAction (XmlNode fileElement)
{
string path = GetAttribute (fileElement, "Path");
XmlDocument doc = new XmlDocument ();
try {
doc.Load (path);
} catch {
Console.WriteLine ("ERROR: Could not open {0}.", path);
return false;
}
Console.WriteLine ("Processing {0}...", path);
foreach (XmlNode element in fileElement.SelectNodes ("Replace"))
if (!ReplaceNode (fileElement.OwnerDocument, doc, element))
return false;
foreach (XmlNode element in fileElement.SelectNodes ("Insert"))
if (!InsertNode (fileElement.OwnerDocument, doc, element))
return false;
foreach (XmlNode element in fileElement.SelectNodes ("Remove"))
if (!RemoveNodes (doc, element))
return false;
doc.Save (path);
Console.WriteLine ("{0} saved.", path);
return true;
}
示例2: SiteDocumentBase
protected SiteDocumentBase(XmlNode xmlNode)
{
this.Name = xmlNode.Attributes["name"].Value;
this.Id = xmlNode.Attributes["id"].Value;
//Note: [2015-10-28] Datasources presently don't return this information
// this.ContentUrl = xmlNode.Attributes["contentUrl"].Value;
//Namespace for XPath queries
var nsManager = XmlHelper.CreateTableauXmlNamespaceManager("iwsOnline");
//Get the project attributes
var projectNode = xmlNode.SelectSingleNode("iwsOnline:project", nsManager);
this.ProjectId = projectNode.Attributes["id"].Value;
this.ProjectName = projectNode.Attributes["name"].Value;
//Get the owner attributes
var ownerNode = xmlNode.SelectSingleNode("iwsOnline:owner", nsManager);
this.OwnerId = ownerNode.Attributes["id"].Value;
//See if there are tags
var tagsNode = xmlNode.SelectSingleNode("iwsOnline:tags", nsManager);
if (tagsNode != null)
{
this.TagsSet = new SiteTagsSet(tagsNode);
}
}
示例3: Load
public override void Load(XmlNode xnode)
{
type = LocalType.Get(xnode.Name);
texture = new Texture();
name = MyXml.GetString(xnode, "name");
variations = MyXml.GetInt(xnode, "variations", 1);
maxHP = MyXml.GetInt(xnode, "hp");
damage = MyXml.GetInt(xnode, "damage");
attack = MyXml.GetInt(xnode, "attack");
defence = MyXml.GetInt(xnode, "defence");
armor = MyXml.GetInt(xnode, "armor");
movementTime = MyXml.GetFloat(xnode, "movementTime");
attackTime = MyXml.GetFloat(xnode, "attackTime");
isWalkable = MyXml.GetBool(xnode, "walkable");
isFlat = MyXml.GetBool(xnode, "flat");
if (xnode.Name == "Thing") isWalkable = true;
string s = MyXml.GetString(xnode, "type");
if (s != "") creatureType = CreatureType.Get(s);
s = MyXml.GetString(xnode, "corpse");
if (creatureType != null && (creatureType.name == "Animal" || creatureType.name == "Sentient")) s = "Blood";
if (s != "") corpse = Get(s);
s = MyXml.GetString(xnode, "onDeath");
if (creatureType != null && creatureType.name == "Animal") s = "Large Chunk of Meat";
if (s != "") onDeath = ItemShape.Get(s);
for (xnode = xnode.FirstChild; xnode != null; xnode = xnode.NextSibling)
abilities.Add(BigBase.Instance.abilities.Get(MyXml.GetString(xnode, "name")));
}
示例4: ReadFromXMLNode
public virtual void ReadFromXMLNode(XmlNode node)
{
try
{
// Read the pylons models
XmlNodeList cableStates = node.SelectNodes(ModelXMLDefinition.CableState);
foreach (XmlNode cableState in cableStates)
{
CCableState normalNode = new CCableState(this, new CCablingConnectionIndicator(new CLineTwoPointsIndicatorsImpl()));
normalNode.ReadFromXMLNode(cableState);
}
//// Set active cable state to the first one if it exists
//if (CableStates != null && CableStates.Count != 0)
//{
// ActiveCableState = CableStates[0];
//}
// Read the cable switch condition
XmlNode cableConditionNode = node.SelectSingleNode(ModelXMLDefinition.CableSwitchCondition);
if (cableConditionNode != null)
{
m_cableSwitchCondition = CCableSwitchConditionFactory.ReadFromXMLNode(cableConditionNode, this);
}
}
catch (SystemException ex)
{
string errMsg = "Read cable data failed:\n" + ex.Message + "\n" + ex.StackTrace;
vtk.vtkOutputWindow.GetInstance().DisplayErrorText(errMsg);
throw;
}
}
示例5: GameInformation
public GameInformation(XmlNode node)
{
if (node ["Title"] != null)
gameName = node ["Title"].InnerText;
if (node ["Description"] != null)
description = node ["Description"].InnerText;
if (node ["LongDescription"] != null)
longDescription = node ["LongDescription"].InnerText;
if (node ["FileLocation"] != null)
programLocation = node ["FileLocation"].InnerText;
if (node ["Arguments"] != null)
arguments = node ["Arguments"].InnerText;
if (node ["Website"] != null)
website = node ["Website"].InnerText;
if (node ["CreationDate"] != null)
releaseDate = node ["CreationDate"].InnerText;
if (node ["NumberOfPlayers"] != null)
requiredPlayers = int.Parse (node ["NumberOfPlayers"].InnerText);
if (node ["Authors"] != null) {
XmlNodeList aths = node ["Authors"].GetElementsByTagName ("Author");
authors = new string[aths.Count];
for (int i = 0; i < aths.Count; i++) {
authors [i] = aths [i].InnerText;
}
}
if (node ["ImageLocation"] != null) {
imagePath = "file://" + Application.dataPath + node ["ImageLocation"].InnerText;
}
}
示例6: DesignationData
public DesignationData( XmlNode node)
{
try
{
SetValue( ref id, node, "SubTitle_ID");
SetValue( ref eType, node, "SubTitle_Type");
SetValue( ref eCategory, node, "SubTitle_Category");
SetValue( ref name, node, "SubTitle_Name");
SetValue( ref nameColor, node, "SubTitle_Color");
SetValue( ref desc, node, "SubTitle_Description1");
SetValue( ref effectDesc, node, "SubTitle_Description2");
SetValue( ref notice, node, "SubTitle_Notice");
SetValue( ref rankPoint, node, "SubTitle_RankPoint");
SetValue( ref DivineKnight_Item_ID, node, "DivineKnight_Item_ID");
SetValue( ref DivineKnight_Item_Count, node, "DivineKnight_Item_Count");
SetValue( ref Magician_Item_ID, node, "Magician_Item_ID");
SetValue( ref Magician_Item_Count, node, "Magician_Item_Count");
SetValue( ref Cleric_Item_ID, node, "Cleric_Item_ID");
SetValue( ref Cleric_Item_Count, node, "Cleric_Item_Count");
SetValue( ref Hunter_Item_ID, node, "Hunter_Item_ID");
SetValue( ref Hunter_Item_Count, node, "Hunter_Item_Count");
}
catch( System.Exception e)
{
Debug.LogError(e);
}
}
示例7: DialogResponse
public DialogResponse(XmlNode xnode)
{
text = MyXml.GetString(xnode, "text");
action = MyXml.GetString(xnode, "action");
jump = MyXml.GetString(xnode, "jump");
condition = MyXml.GetString(xnode, "condition");
}
示例8: GetName
public static Name GetName(XmlNode node)
{
string first_name = GetField (node, "t:name/t:first-name");
string last_name = GetField (node, "t:name/t:last-name");
return new Name (first_name, last_name);
}
示例9: Level
public Level(XmlNode data)
{
this.data = data;
target = data.FindSkills().First();
level = data.GetInt();
xp = data.Child(XP).GetFloat();
}
示例10: Parse
public static bool Parse( /*in*/ XmlNode _TableNode ,
out InterpolateTable _Result )
{
InterpolatePair anewPair = null ;
_Result = new InterpolateTable() ;
if( null != _TableNode.Attributes[ "name" ] )
{
_Result.m_Name =_TableNode.Attributes[ "name" ].Value ;
if( _TableNode.HasChildNodes )
{
for( int i = 0 ; i < _TableNode.ChildNodes.Count ; ++i )
{
if( "InterpolatePair" == _TableNode.ChildNodes[ i ].Name )
{
if( true == XMLParseInterpolatePair.Parse( _TableNode.ChildNodes[ i ] ,
out anewPair ) )
{
_Result.m_Table.Add( anewPair ) ;
}
}
}
}
return true ;
}
return false ;
}
示例11: SerializedObjectNode
/// <summary>
/// Creates a serialized object from an XmlNode that is the child of a parent node
/// </summary>
/// <param name="node">The xml node that this serialized object is wrapping</param>
/// <param name="parentNode">The parent node that we are a part of</param>
protected SerializedObjectNode(XmlNode node, SerializedObjectNode parentNode)
{
m_xmlNode = node;
m_parentNode = parentNode;
if (m_xmlNode.Attributes != null)
{
XmlAttribute versionAttribute = m_xmlNode.Attributes["version"];
if (versionAttribute != null)
{
string fullVersionString = versionAttribute.Value;
while (!string.IsNullOrEmpty(fullVersionString))
{
int versionNameDelimiterIndex = fullVersionString.IndexOf(',');
string versionName = versionNameDelimiterIndex < 0 ? fullVersionString : fullVersionString.Substring(0, versionNameDelimiterIndex);
if (versionNameDelimiterIndex > -1)
fullVersionString = fullVersionString.Substring(versionNameDelimiterIndex + 1);
else
fullVersionString = null;
SerializedVersionInfo newVersionInfo = SerializedVersionInfo.Parse(versionName);
m_versionInfo.AddFirst(newVersionInfo);
}
}
}
foreach (XmlNode childNode in m_xmlNode.ChildNodes)
{
SerializedObjectNode newChildNode = new SerializedObjectNode(childNode, this);
m_children.Add(childNode.Name, newChildNode);
}
}
示例12: GetXmlAttrIntss
public static List<List<int>> GetXmlAttrIntss(XmlNode node, string key)
{
//Debug.Log(key);
int num = 0;
List<List<int>> result = new List<List<int>>();
string str = node.Attributes[key].InnerText;
if (!string.IsNullOrEmpty(str))
{
string[] strs = str.Split(',');
foreach (string item in strs)
{
List<int> r = new List<int>();
string[] items = item.Split('|');
foreach (string s in items)
{
if (int.TryParse(s, out num))
{
r.Add(num);
}
}
result.Add(r);
}
}
return result;
}
示例13: xmlToVo
public override void xmlToVo(XmlNode node)
{
XmlElement xmlelement = (XmlElement)node;
id = int.Parse(xmlelement.GetAttribute("id"));
name = xmlelement.GetAttribute("name");
age = int.Parse(xmlelement.GetAttribute("age"));
}
示例14: loadMedium
/*!
\brief This function create a new Medium based on the information in the given XML Node
\param node The XmlNode to load.
\return Return the new Medium
*/
public Medium loadMedium(XmlNode node)
{
Medium medium = new Medium();
foreach (XmlNode attr in node)
{
switch (attr.Name)
{
case "Id":
medium.setId(Convert.ToInt32(attr.InnerText));
break;
case "Name":
medium.setName(attr.InnerText);
break;
case "Energy":
loadEnergy(attr.InnerText, medium);
break;
case "EnergyProductionRate":
loadEnergyProductionRate(attr.InnerText, medium);
break;
case "MaxEnergy":
loadMaxEnergy(attr.InnerText, medium);
break;
case "ReactionsSet":
medium.setReactionsSet(attr.InnerText);
break;
case "MoleculesSet":
medium.setMoleculesSet(attr.InnerText);
break;
}
}
return medium;
}
示例15: FromXMLVector2
public static Vector2 FromXMLVector2(XmlNode node)
{
Vector2 output = new Vector3();
output.x = float.Parse(node["x"].FirstChild.Value);
output.y = float.Parse(node["y"].FirstChild.Value);
return output;
}