本文整理汇总了C#中System.Xml.XmlElement.SelectNodes方法的典型用法代码示例。如果您正苦于以下问题:C# XmlElement.SelectNodes方法的具体用法?C# XmlElement.SelectNodes怎么用?C# XmlElement.SelectNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlElement
的用法示例。
在下文中一共展示了XmlElement.SelectNodes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoParse
protected override void DoParse(XmlElement element, ParserContext parserContext, ObjectDefinitionBuilder builder)
{
builder.AddPropertyReference(TxNamespaceUtils.TRANSACTION_MANAGER_PROPERTY,
GetAttributeValue(element, TxNamespaceUtils.TRANSACTION_MANAGER_ATTRIBUTE));
XmlNodeList txAttributes = element.SelectNodes("*[local-name()='attributes' and namespace-uri()='" + element.NamespaceURI + "']");
if (txAttributes.Count > 1 )
{
parserContext.ReaderContext.ReportException(element, "tx advice", "Element <attributes> is allowed at most once inside element <advice>");
}
else if (txAttributes.Count == 1)
{
//using xml defined source
XmlElement attributeSourceElement = txAttributes[0] as XmlElement;
AbstractObjectDefinition attributeSourceDefinition =
ParseAttributeSource(attributeSourceElement, parserContext);
builder.AddPropertyValue(TxNamespaceUtils.TRANSACTION_ATTRIBUTE_SOURCE, attributeSourceDefinition);
}
else
{
//Assume attibutes source
ObjectDefinitionBuilder txAttributeSourceBuilder =
parserContext.ParserHelper.CreateRootObjectDefinitionBuilder(typeof (AttributesTransactionAttributeSource));
builder.AddPropertyValue(TxNamespaceUtils.TRANSACTION_ATTRIBUTE_SOURCE,
txAttributeSourceBuilder.ObjectDefinition);
}
}
示例2: RecursiveCreatePageControl
public static List<PageControl> RecursiveCreatePageControl(XmlElement root)
{
var result = new List<PageControl>();
var nodeList = root.SelectNodes("Children/Child");
if (nodeList.Count <= 0)
{
nodeList = root.SelectNodes("Child");
}
foreach (XmlNode node in nodeList)
{
var element = node as XmlElement;
var control = new PageControl();
control.Id = XmlUtility.GetAttrValue(element, "Id");
control.Type = XmlUtility.GetAttrValue(element, "Type");
var dynamicProperty = new DynamicProperty();
dynamicProperty.InitProperty();
var flashProperty = new FlashProperty();
flashProperty.InitProperty();
EvaluateProperty(element, control, dynamicProperty, flashProperty);
EvaluateEvent(element, control, dynamicProperty, flashProperty);
if (dynamicProperty.FlashEvents.Count > 0
|| dynamicProperty.FlashPropertys.Count > 0)
{
control.Properties.Add(new Property()
{
Name = PropertyUtility.DYNAMICNAME,
Type = PropertyValueType.str.ToString(),
Value = dynamicProperty.ToXml()
});
}
control.Children = RecursiveCreatePageControl(element);
result.Add(control);
}
return result;
}
示例3: EnumeratedFieldMapping
public EnumeratedFieldMapping(XmlElement elem, XmlElement parentElem)
{
NodeName = elem.Attributes["NodeName"].Value;
FieldName = elem.Attributes["FieldName"].Value;
MissingFieldValue = XmlUtils.GetOptionalAttribute(elem, "MissingFieldValue");
AttrName = XmlUtils.GetOptionalAttribute(elem, "AttrName");
if (string.IsNullOrEmpty(AttrName))
AttrName = "val";
foreach (XmlElement subElem in elem.SelectNodes("./x:AttributeValueMapping", GenerationContext.NamespaceManager))
{
attrValueMappings.Add(subElem.Attributes["AttrValue"].Value, subElem.Attributes["FieldValue"].Value);
}
foreach (XmlElement subElem in elem.SelectNodes("./x:EnumerationMappingReference", GenerationContext.NamespaceManager))
{
string enumMappingRefName = subElem.GetAttribute("ref");
foreach (XmlElement enumElem in parentElem.ParentNode.SelectNodes("./x:EnumerationMappingDefinition", GenerationContext.NamespaceManager))
{
if (enumElem.GetAttribute("name") == enumMappingRefName)
{
foreach (XmlElement inElem in enumElem.SelectNodes("./x:AttributeValueMapping", GenerationContext.NamespaceManager))
{
attrValueMappings.Add(inElem.Attributes["AttrValue"].Value, inElem.Attributes["FieldValue"].Value);
}
}
}
}
}
示例4: ObjectConfigurationType
/// <summary>
/// Initializes a new instance of the <see cref="ObjectConfigurationType"/> class.
/// </summary>
/// <param name="node">The node.</param>
public ObjectConfigurationType(XmlElement node)
{
properties = new List<PropertyConfigurationType>();
constructorArgs = new List<PropertyConfigurationType>();
name = node.GetAttribute(NameAttr);
type = node.GetAttribute(TypeAttr);
XmlNodeList nodeProperties = node.SelectNodes(PropertyElement);
foreach (XmlNode nodeProperty in nodeProperties)
{
properties.Add(new PropertyConfigurationType((XmlElement)nodeProperty));
}
var nodeConstructorArgs = node.SelectNodes(ConstructorArgElement);
const int FIRST_INDEX = 0;
var index = FIRST_INDEX;
var argMap = new SortedDictionary<int, PropertyConfigurationType>();
foreach (XmlNode nodeConstructorArg in nodeConstructorArgs)
{
var el = (XmlElement)nodeConstructorArg;
if (!string.IsNullOrEmpty(el.GetAttribute(IndexAttr)))
{
index = Convert.ToInt32(el.GetAttribute(IndexAttr));
}
argMap[index++] = new PropertyConfigurationType(el);
}
if (nodeConstructorArgs.Count > 0 && !argMap.ContainsKey(FIRST_INDEX))
{
throw new ConfigurationErrorsException("constructor-arg index must start at: " + FIRST_INDEX);
}
constructorArgs.AddRange(argMap.Values);
}
示例5: WorkItemTypeDefinition
public WorkItemTypeDefinition(XmlElement witdElement, bool isWritable)
{
if (witdElement.SelectSingleNode("WORKITEMTYPE") == null)
{
throw new ArgumentException("Invalid definition document, missing WORKITEMTYPE element.");
}
_witdElement = (XmlElement)witdElement.Clone();
_isWritable = isWritable;
if (!_isWritable)
{
_fields = _witdElement
.SelectNodes("WORKITEMTYPE/FIELDS/FIELD")
.Cast<XmlElement>()
.Select(e => new WitdField(e))
.ToArray();
_states = _witdElement
.SelectNodes("WORKITEMTYPE/WORKFLOW/STATES/STATE")
.Cast<XmlElement>()
.Select(e => new WitdState(e))
.ToArray();
_transitions = new HashSet<WitdTransition>(witdElement
.SelectNodes("WORKITEMTYPE/WORKFLOW/TRANSITIONS/TRANSITION")
.Cast<XmlElement>()
.Select(e => new WitdTransition(e)));
}
}
示例6: Question
/**
<Question type="checkedlistbox" label="血型" />
* */
public Question(string subjectName, List<QuestionListItem> listItems, XmlElement question)
{
this.subjectName = subjectName;
this.listItems = listItems;
this.qType = question.GetAttribute("type");
this.qName = question.GetAttribute("name");
this.qLabel = question.GetAttribute("label");
this.qWidth = question.GetAttribute("width");
this.qRows = question.GetAttribute("rows");
if (string.IsNullOrEmpty(this.qRows))
this.qRows = "2"; //Default value;
//parse column definitions
this.columns = new List<GridColumn>();
foreach (XmlElement xmlCol in question.SelectNodes("Cols/Col"))
{
this.columns.Add(new GridColumn(xmlCol));
}
//parse default values
this.defaultRecords = new List<Dictionary<string, string>>();
foreach (XmlElement xmlItem in question.SelectNodes("Default/Item")) //every record
{
Dictionary<string, string> key_values = new Dictionary<string, string>();
this.defaultRecords.Add(key_values);
foreach (XmlElement elmField in xmlItem.SelectNodes("Field"))
{
key_values.Add(elmField.GetAttribute("key"), elmField.GetAttribute("value"));
}
}
}
示例7: QuestionGroup
private string tempLabel = ""; //如果label = "" 時,會造成 SubjectUIMaker 中的 Dictionary 會重覆""
#endregion Fields
#region Constructors
public QuestionGroup(XmlElement elmQGDef)
{
this.elmQGDef = elmQGDef;
//parse titleName
this.label = elmQGDef.GetAttribute("label");
this.labelWidth = elmQGDef.GetAttribute("width");
//如果label = "" 時,可能會造成 Subject 中的 Dictionary 會重覆"",所以先給他一個 Guid 值
if (string.IsNullOrEmpty(this.label))
this.tempLabel = Guid.NewGuid().ToString();
else
this.tempLabel = this.label;
//parse hideLabel attribute
this.showLabel = (elmQGDef.GetAttribute("hideLabel").ToUpper() != "TRUE");
//parse ListItems
this.listItems = new List<QuestionListItem>();
foreach (XmlElement elm in elmQGDef.SelectNodes("Choices/Item"))
{
this.listItems.Add(new QuestionListItem(elm));
}
//Questions
this.questions = new List<Question>();
foreach (XmlElement elm in elmQGDef.SelectNodes("Qs/Q"))
{
Question q = new Question(this.label, this.listItems, elm);
this.questions.Add(q);
}
}
示例8: ItemDescriptor
protected ItemDescriptor(XmlElement elem, ItemGroup group, ClassDescriptor klass)
{
this.klass = klass;
isInternal = elem.HasAttribute ("internal");
deps = AddSubprops (elem.SelectNodes ("./disabled-if"), group, klass);
visdeps = AddSubprops (elem.SelectNodes ("./invisible-if"), group, klass);
targetGtkVersion = elem.GetAttribute ("gtk-version");
if (targetGtkVersion.Length == 0)
targetGtkVersion = null;
}
示例9: Read
public static NeatGenome Read(XmlElement xmlGenome)
{
int inputNeuronCount=0;
int outputNeuronCount=0;
uint id = uint.Parse(XmlUtilities.GetAttributeValue(xmlGenome, "id"));
//--- Read neuron genes into a list.
NeuronGeneList neuronGeneList = new NeuronGeneList();
XmlNodeList listNeuronGenes = xmlGenome.SelectNodes("neurons/neuron");
foreach(XmlElement xmlNeuronGene in listNeuronGenes)
{
NeuronGene neuronGene = ReadNeuronGene(xmlNeuronGene);
// Count the input and output neurons as we go.
switch(neuronGene.NeuronType)
{
case NeuronType.Input:
inputNeuronCount++;
break;
case NeuronType.Output:
outputNeuronCount++;
break;
}
neuronGeneList.Add(neuronGene);
}
//--- Read module genes into a list.
List<ModuleGene> moduleGeneList = new List<ModuleGene>();
XmlNodeList listModuleGenes = xmlGenome.SelectNodes("modules/module");
foreach (XmlElement xmlModuleGene in listModuleGenes) {
moduleGeneList.Add(ReadModuleGene(xmlModuleGene));
}
//--- Read connection genes into a list.
ConnectionGeneList connectionGeneList = new ConnectionGeneList();
XmlNodeList listConnectionGenes = xmlGenome.SelectNodes("connections/connection");
foreach(XmlElement xmlConnectionGene in listConnectionGenes)
connectionGeneList.Add(ReadConnectionGene(xmlConnectionGene));
//return new NeatGenome(id, neuronGeneList, connectionGeneList, inputNeuronCount, outputNeuronCount);
NeatGenome g = new NeatGenome(id, neuronGeneList, moduleGeneList, connectionGeneList, inputNeuronCount, outputNeuronCount);
g.Behavior = ReadBehavior(xmlGenome.SelectSingleNode("behavior"));
g.Behavior.objectives = new double[6];
g.objectives = new double[6];
// JUSTIN: Read grid/trajectory info
g.GridCoords = ReadGrid(xmlGenome.SelectSingleNode("grid"));
g.Behavior.trajectory = ReadTrajectory(xmlGenome.SelectSingleNode("trajectory"));
return g;
}
示例10: ModularXmlLanguageDefinition
/// <summary>
/// Initializes a new instance of the <see cref="ModularXmlLanguageDefinition"/> class.
/// </summary>
/// <param name="languageElement">The XML element that defines the language.</param>
public ModularXmlLanguageDefinition(XmlElement languageElement)
{
Contract.Requires<ArgumentNullException>(languageElement != null);
XmlNamespaceManager nm = Sage.XmlNamespaces.Manager;
this.Name = languageElement.GetAttribute("name");
foreach (XmlElement groupNode in languageElement.SelectNodes("mod:elements/mod:group", nm))
this.Elements.Add(new ExpressionGroup(groupNode, true));
foreach (XmlElement groupNode in languageElement.SelectNodes("mod:attributes/mod:group", nm))
this.Attributes.Add(new ExpressionGroup(groupNode, true));
}
示例11: Read
public static NeatGenome Read(XmlElement xmlGenome)
{
int inputNeuronCount=0;
int outputNeuronCount=0;
uint id = uint.Parse(XmlUtilities.GetAttributeValue(xmlGenome, "id"));
// Schrum: Retrieve this new property, which is saved to xml files now
int outputsPerPolicy = int.Parse(XmlUtilities.GetAttributeValue(xmlGenome, "outputsperpolicy"));
//--- Read neuron genes into a list.
NeuronGeneList neuronGeneList = new NeuronGeneList();
XmlNodeList listNeuronGenes = xmlGenome.SelectNodes("neurons/neuron");
foreach(XmlElement xmlNeuronGene in listNeuronGenes)
{
NeuronGene neuronGene = ReadNeuronGene(xmlNeuronGene);
// Count the input and output neurons as we go.
switch(neuronGene.NeuronType)
{
case NeuronType.Input:
inputNeuronCount++;
break;
case NeuronType.Output:
outputNeuronCount++;
break;
}
neuronGeneList.Add(neuronGene);
}
//--- Read module genes into a list.
List<ModuleGene> moduleGeneList = new List<ModuleGene>();
XmlNodeList listModuleGenes = xmlGenome.SelectNodes("modules/module");
foreach (XmlElement xmlModuleGene in listModuleGenes) {
moduleGeneList.Add(ReadModuleGene(xmlModuleGene));
}
//--- Read connection genes into a list.
ConnectionGeneList connectionGeneList = new ConnectionGeneList();
XmlNodeList listConnectionGenes = xmlGenome.SelectNodes("connections/connection");
foreach(XmlElement xmlConnectionGene in listConnectionGenes)
connectionGeneList.Add(ReadConnectionGene(xmlConnectionGene));
//return new NeatGenome(id, neuronGeneList, connectionGeneList, inputNeuronCount, outputNeuronCount);
//return new NeatGenome(id, neuronGeneList, moduleGeneList, connectionGeneList, inputNeuronCount, outputNeuronCount);
// Schrum: Changed to include the outputs per policy
return new NeatGenome(id, neuronGeneList, moduleGeneList, connectionGeneList, inputNeuronCount, outputNeuronCount, outputsPerPolicy);
}
示例12: Load
/// <summary>
/// 從XML載入設定值
/// <![CDATA[
/// ]]>
/// </summary>
/// <param name="data"></param>
public void Load(XmlElement data)
{
RefStudentID = data.GetAttribute("RefStudentID");
Permanent = new AddressItem(data.SelectSingleNode("Permanent/Address") as XmlElement);
Mailing = new AddressItem(data.SelectSingleNode("Mailing/Address") as XmlElement);
Address1 = new AddressItem(null);
Address2 = new AddressItem(null);
Address3 = new AddressItem(null);
int index = 0;
foreach (XmlElement each in data.SelectNodes("Addresses/AddressList/Address"))
{
if (index == 0)
Address1 = new AddressItem(each);
if (index == 1)
Address2 = new AddressItem(each);
if (index == 2)
Address3 = new AddressItem(each);
index++;
}
}
示例13: GetElementByAttribute
public static XmlElement GetElementByAttribute( XmlElement parent,
string elementName,
string attributeName,
string attributeValue,
bool filtered )
{
if ( parent == null || elementName == null || attributeName == null ||
attributeValue == null ) {
return null;
}
// TODO: Implement better filtering in the xpath expression so that the multiple steps of operations are not necessary
XmlElement element = null;
string xPath = elementName + "[@" + attributeName + "=\"" + attributeValue + "\"]";
if ( filtered ) {
FilteredElementList list = new FilteredElementList( parent.SelectNodes( xPath ) );
IEnumerator enumerator = list.GetEnumerator();
if ( enumerator.MoveNext() ) {
element = (XmlElement) enumerator.Current;
}
}
else {
element = (XmlElement) parent.SelectSingleNode( xPath );
}
return element;
}
示例14: StoreMemberProperty
internal StoreMemberProperty(EDMXFile parentFile, StoreEntityType storeEntityType, string name, int ordinal, XmlElement parentTypeElement)
: base(parentFile)
{
_parentEntityType = storeEntityType;
_parentEntityType.Removed += new EventHandler(ParentEntityType_Removed);
_propertyElement = EDMXDocument.CreateElement("Property", NameSpaceURIssdl);
if (ordinal > 0)
{
XmlNodeList propertyNodes = parentTypeElement.SelectNodes("ssdl:Property", NSM);
if (propertyNodes.Count >= ordinal)
{
parentTypeElement.InsertAfter(_propertyElement, propertyNodes[ordinal - 1]);
}
else
{
parentTypeElement.AppendChild(_propertyElement);
}
}
else
{
parentTypeElement.AppendChild(_propertyElement);
}
this.Name = name;
}
示例15: DeserializeCore
protected override void DeserializeCore(XmlElement element, SaveContext context)
{
base.DeserializeCore(element, context); //Base implementation must be called
if (context == SaveContext.Undo)
{
//Reads in the new number of ports required from the data stored in the Xml Element
//during Serialize (nextLength). Changes the current In Port Data to match the
//required size by adding or removing port data.
int currLength = InPortData.Count;
XmlNodeList inNodes = element.SelectNodes("Input");
int nextLength = inNodes.Count;
if (nextLength > currLength)
{
for (; currLength < nextLength; currLength++)
{
XmlNode subNode = inNodes.Item(currLength);
string nickName = subNode.Attributes["name"].Value;
InPortData.Add(new PortData(nickName, "", typeof(object)));
}
}
else if (nextLength < currLength)
InPortData.RemoveRange(nextLength, currLength - nextLength);
RegisterAllPorts();
}
}