本文整理汇总了C#中XmlNode.SelectNodes方法的典型用法代码示例。如果您正苦于以下问题:C# XmlNode.SelectNodes方法的具体用法?C# XmlNode.SelectNodes怎么用?C# XmlNode.SelectNodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlNode
的用法示例。
在下文中一共展示了XmlNode.SelectNodes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MenuElement
public MenuElement(XmlNode node)
{
this.bundleName = node.Attributes["assetBundle"].Value;
XmlNodeList cs = node.SelectNodes("//c");
foreach (XmlNode c in cs){
sources.Add(c.Attributes["src"].Value);
}
cs = node.SelectNodes("//img");
foreach (XmlNode c in cs){
if (c.Attributes["src"] != null)
sources.Add(c.Attributes["src"].Value);
}
cs = node.SelectNodes("//spot");
foreach (XmlNode c in cs){
if (c.Attributes["src"] != null)
sources.Add(c.Attributes["src"].Value);
}
// timeline
cs = node.SelectNodes("//ms");
if (cs.Count > 0){
sources.Add("timelinebg");
sources.Add("timelinearrow");
foreach (XmlNode c in cs){
sources.Add(c.Attributes["time"].Value);
sources.Add(c.Attributes["text"].Value);
sources.Add(c.Attributes["pic"].Value);
}
}
}
示例2: 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;
}
示例3: ParseMap
private void ParseMap(XmlNode mapNode)
{
var tilesetsXmlNodeList = mapNode.SelectNodes("tileset");
if (tilesetsXmlNodeList != null) ParseTileSets(tilesetsXmlNodeList);
else Debug.LogError("Unable to parse the map file, no <tileset> element found for <map>.");
var tilellayerXmlNodeList = mapNode.SelectNodes("layer");
if (tilellayerXmlNodeList != null) ParseTileLayers(tilellayerXmlNodeList);
else Debug.LogError("Unable to parse the map file, no <layer> element found for <map>.");
//_mapLoaded = true;
Debug.Log("Parsed map.");
}
示例4: checkHave
private static bool checkHave(XmlNode haveReq)
{
int haveQuantity = UserProperty.GetPropNode(haveReq.getString()).GetInt();
foreach (XmlNode atLeast in haveReq.SelectNodes(AT_LEAST)) {
if (MathData.GetInt(atLeast) > haveQuantity) {
return false;
}
}
foreach (XmlNode exactly in haveReq.SelectNodes(EXACTLY)) {
if (MathData.GetInt(exactly) != haveQuantity) {
return false;
}
}
return true;
}
示例5: loadPromoters
public bool loadPromoters(XmlNode node, LinkedList<IReaction> reactions)
{
XmlNodeList promotersList = node.SelectNodes("promoter");
bool b = true;
foreach (XmlNode promoter in promotersList)
{
Promoter p = new Promoter();
foreach (XmlNode attr in promoter)
{
switch (attr.Name)
{
case "name":
b = b && loadPromoterName(attr.InnerText, p);
break;
case "productionMax":
b = b && loadPromoterProductionMax(attr.InnerText, p);
break;
case "terminatorFactor":
b = b && loadPromoterTerminatorFactor(attr.InnerText, p);
break;
case "formula":
b = b && loadPromoterFormula(attr.InnerText, p);
break;
case "operon":
b = b && loadPromoterOperon(attr, p);
break;
}
}
reactions.AddLast(p);
}
return b;
}
示例6: Deserialize
public static SkillData Deserialize(XmlNode dataui, XmlNode data)
{
SkillData _SkillData = ScriptableObject.CreateInstance<SkillData>();
_SkillData.Name = dataui.Attributes["name"].Value;
_SkillData.Id = int.Parse(dataui.Attributes["id"].Value);
//=========变量初始化
XmlNodeList childs = data.SelectNodes("variables/var");
foreach (XmlNode child in childs)
{
SharedVariable sharedVariable = ScriptableObject.CreateInstance(string.Format("Shared{0}",child.Attributes["type"].Value )) as SharedVariable;
sharedVariable.name = child.Attributes["name"].Value;
sharedVariable.IsShared = true;
_SkillData.Variables.Add(sharedVariable.name,sharedVariable);
}
//==========模块初始化
List<Task> list = new List<Task>();
childs = dataui.SelectNodes("item");
foreach (XmlNode child in childs)
{
string k = child.Attributes["ID"].Value;
XmlNode k1 = data.SelectSingleNode(@"*[@id=" + k + "]");
Task tk = DeserializeTask(child, k1, _SkillData);
list.Add(tk);
}
_SkillData.Datas = list;
return _SkillData;
}
示例7: loadInstantReactions
public bool loadInstantReactions(XmlNode node, LinkedList<IReaction> reactions)
{
XmlNodeList IReactionsList = node.SelectNodes("instantReaction");
bool b = true;
foreach (XmlNode IReaction in IReactionsList)
{
InstantReaction ir = new InstantReaction();
foreach (XmlNode attr in IReaction)
{
switch (attr.Name)
{
case "name":
ir.setName(attr.InnerText);
break;
case "reactants":
loadInstantReactionReactants(attr, ir);
break;
case "products":
loadInstantReactionProducts(attr, ir);
break;
}
}
reactions.AddLast(ir);
}
return b;
}
示例8: 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;
}
}
示例9: RGBTreePreviewDialog
public RGBTreePreviewDialog(XmlNode setupNode, IList<Channel> channels)
{
InitializeComponent();
if (null == setupNode || null == setupNode.Attributes || null == setupNode.Attributes["from"] ||
null == setupNode.SelectNodes("Channels/Channel")) {
throw new NullReferenceException("setupNode has a null value in a non-null field");
}
Width = ParseNode(setupNode.SelectSingleNode("Settings/Width"), Screen.PrimaryScreen.WorkingArea.Width);
Height = ParseNode(setupNode.SelectSingleNode("Settings/Height"), Screen.PrimaryScreen.WorkingArea.Width);
_drawSize = ParseNode(setupNode.SelectSingleNode("Settings/PixelSize"), DrawSizeDefault);
ClientSize = new Size(Width, Height);
pictureBox.Size = new Size(Width, Height);
// Checked above stupid resharper.
// ReSharper disable once PossibleNullReferenceException
var startChannel = int.Parse(setupNode.Attributes["from"].Value) - 1;
_channelDictionary = new Dictionary<int, List<uint>>();
// Checked above stupid resharper.
// ReSharper disable once PossibleNullReferenceException
foreach (XmlNode xmlNode in setupNode.SelectNodes("Channels/Channel")) {
if (xmlNode.Attributes == null) {
continue;
}
var channelNumber = Convert.ToInt32(xmlNode.Attributes["number"].Value);
if (channelNumber < startChannel) {
continue;
}
var outputChannel = new List<uint>();
var encodedChannelData = Convert.FromBase64String(xmlNode.InnerText);
var startIndex = 0;
while (startIndex < encodedChannelData.Length) {
outputChannel.Add(BitConverter.ToUInt32(encodedChannelData, startIndex));
startIndex += 4;
}
_channelDictionary[channels[channelNumber - startChannel].OutputChannel] = outputChannel;
}
}
示例10: ParseTileLayer
/// <summary>
/// Parses the example xml element structure to an object of this type:
/// <note>
/// <layer name="background" width="20" height="20">
/// <data>
/// <tile gid="1"/>
/// ...
/// </data>
/// </layer>
/// </note>
/// </summary>
/// <param name="tileLayerXmlNode"></param>
/// <param name="map"></param>
/// <returns></returns>
public static TileLayer ParseTileLayer(XmlNode tileLayerXmlNode, TileMap map)
{
int widht = int.Parse(tileLayerXmlNode.Attributes["width"].Value);
int height = int.Parse(tileLayerXmlNode.Attributes["height"].Value);
string name = tileLayerXmlNode.Attributes["name"].Value;
Tile[,] data = ParseTiles(tileLayerXmlNode.SelectNodes("data/tile"), map, widht, height);
return new TileLayer(widht, height, name, data);
}
示例11: Get_Random_User
public string Get_Random_User()
{
summon_db.Load("Assets/Scripts/Grimoire/Database/SummonDatabase.xml");
summon_root = summon_db.DocumentElement;
XmlNodeList users = summon_root.SelectNodes("//Summon");
XmlNode random_user = users[UnityEngine.Random.Range(0, users.Count)];
string name = random_user.Attributes.Item(0).Value;
return name;
}
示例12: checkHave
private static bool checkHave(XmlNode haveReq)
{
int haveQuantity = int.Parse(UserProperty.getProp(haveReq.Attributes[XmlUtilities.data].Value));
foreach (XmlNode atLeast in haveReq.SelectNodes(XmlUtilities.atLeast)) {
if (int.Parse(atLeast.Attributes[XmlUtilities.data].Value) > haveQuantity) {
return false;
}
}
return true;
}
示例13: apply
public static void apply(XmlNode consequence)
{
foreach (XmlNode change in consequence.SelectNodes(CHANGE)) {
string changeProp = change.getString();
foreach (XmlNode add in change.SelectNodes(ADD)) {
int delta = MathData.GetInt(add);
UserProperty.setProp(changeProp,
(UserProperty.GetPropNode(changeProp).GetInt() + delta).ToString()
);
}
foreach (XmlNode mult in change.SelectNodes(MULTIPLY)) {
int factor = MathData.GetInt(mult);
UserProperty.setProp(changeProp,
(UserProperty.GetPropNode(changeProp).GetInt() * factor).ToString()
);
}
}
foreach (XmlNode newNameNode in consequence.SelectNodes(LEARN_NAME)) {
string newName = newNameNode.getString();
foreach (string oldName in newNameNode.childNode(BEFORE_CALLED).getStrings()) {
Regex regex = new Regex(string.Format("^({0}):", oldName));
foreach (string setting in newNameNode.childNode(APPEARS_IN).getStrings()) {
XmlNode uProp = UserProperty.GetPropNode(setting);
foreach (XmlNode replaceable in uProp.GetStringNodes()) {
replaceable.SetString(regex.Replace(replaceable.getString(), delegate(Match m) {
return newName + ":";
}));
}
}
}
}
foreach (XmlNode addLines in consequence.SelectNodes(ADD_STRING)) {
XmlNode dialog = UserProperty.GetPropNode(addLines.childNode(STRING_TARGET).getString());
foreach (string line in addLines.getStrings()) {
dialog.CreateStringNode().SetString(line);
}
}
if (consequence.childNode(WIPE_USER_STATE) != null) {
UserProperty.Wipe();
UserProperty.ForceReload();
}
}
示例14: SerialiseSoundBank
static void SerialiseSoundBank(XmlNode node)
{
XmlNodeList includedEvents = node.SelectNodes("IncludedEvents");
for (int i = 0; i < includedEvents.Count; i++)
{
XmlNodeList events = includedEvents[i].SelectNodes("Event");
for (int j = 0; j < events.Count; j++)
{
SerialiseMaxAttenuation(events[j]);
}
}
}
示例15: loadEnzymeReactions
/*!
\brief Load all enzymatic reactions from an xml node
\param node The xml node
\param reactions The list of reactions
\return Return true if succed, false otherwise
*/
public bool loadEnzymeReactions(XmlNode node, LinkedList<IReaction> reactions)
{
XmlNodeList EReactionsList = node.SelectNodes("enzyme");
bool b = true;
foreach (XmlNode EReaction in EReactionsList)
{
EnzymeReaction er = new EnzymeReaction();
foreach (XmlNode attr in EReaction)
{
switch (attr.Name)
{
case "name":
b = b && loadEnzymeString(attr.InnerText, er.setName);
break;
case "substrate":
b = b && loadEnzymeString(attr.InnerText, er.setSubstrate);
break;
case "enzyme":
b = b && loadEnzymeString(attr.InnerText, er.setEnzyme);
break;
case "Kcat":
b = b && loadEnzymeFloat(attr.InnerText, er.setKcat);
break;
case "effector":
b = b && loadEnzymeString(attr.InnerText, er.setEffector);
break;
case "alpha":
b = b && loadEnzymeFloat(attr.InnerText, er.setAlpha);
break;
case "EnergyCost":
b = b && loadEnzymeFloat(attr.InnerText, er.setEnergyCost);
break;
case "beta":
b = b && loadEnzymeFloat(attr.InnerText, er.setBeta);
break;
case "Km":
b = b && loadEnzymeFloat(attr.InnerText, er.setKm);
break;
case "Ki":
b = b && loadEnzymeFloat(attr.InnerText, er.setKi);
break;
case "Products":
b = b && loadEnzymeReactionProducts(attr, er);
break;
}
}
reactions.AddLast(er);
}
return b;
}