当前位置: 首页>>代码示例>>C#>>正文


C# XmlElement.GetElementsByTagName方法代码示例

本文整理汇总了C#中XmlElement.GetElementsByTagName方法的典型用法代码示例。如果您正苦于以下问题:C# XmlElement.GetElementsByTagName方法的具体用法?C# XmlElement.GetElementsByTagName怎么用?C# XmlElement.GetElementsByTagName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XmlElement的用法示例。


在下文中一共展示了XmlElement.GetElementsByTagName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Conversation

    public Conversation(XmlElement element, LineCatalogue catalogue)
    {
        persistentConversation = new PersistentConversation();
        persistentConversation.name = element.GetAttribute("name");

        if(SaveLoad.SaveExits()) {
            PersistentConversation tmp = (PersistentConversation)SaveLoad.ReadSaveFile(PersistentConversation.GetSaveFileName(persistentConversation.name));
            if(tmp != null) {
                persistentConversation = tmp;
            }
            else {
                SaveLoad.ResetSave();
            }

        }

        //Debug.Log("Conversation.Conversation() name=" + persistentConversation.name );
        participants = new ArrayList();
        XmlNodeList participantNodeList = element.GetElementsByTagName("participant");
        foreach (XmlElement participantElement in participantNodeList){
            string participantName = participantElement.GetAttribute("name");
            participants.Add(CharacterManager.GetCharacter(participantName));
        }

        XmlElement rootLineElement = (XmlElement)element.GetElementsByTagName("root_line").Item(0);
        rootLine = new RootLine(rootLineElement, catalogue, this);
        rootLine.ConnectLinks(catalogue);
        currentController = null;
    }
开发者ID:kiichi7,项目名称:Lies_and_Seductions,代码行数:29,代码来源:Conversation.cs

示例2: ReadFile

 public static void ReadFile(String path)
 {
     doc = new XmlDocument();
      doc.Load(path);    //加载Xml文件
      rootElem = doc.DocumentElement;   //获取根节点
      wallNodes = rootElem.GetElementsByTagName("archi-wall");
      polylines = rootElem.GetElementsByTagName("aux-polyline");
      windowsNodes = rootElem.GetElementsByTagName("archi-window");
      doorNodes = rootElem.GetElementsByTagName("archi-door");
      archi_info = rootElem.GetElementsByTagName("archi-info");
      sizex = float.Parse(((XmlElement)archi_info[0]).GetAttribute("sizex"))/scalar;
      sizez = float.Parse(((XmlElement)archi_info[0]).GetAttribute("sizez"))/scalar;
 }
开发者ID:MartinXM,项目名称:WordEye,代码行数:13,代码来源:XMLParser.cs

示例3: Initialize

 private void Initialize(XmlElement content)
 {
     XmlNodeList list = content.GetElementsByTagName("ChatMessage");
     XmlElement element = (XmlElement)list.Item(0);
     if(element.HasAttribute("originator"))
     {
         this._originator = element.GetAttribute("originator");
     }
     if(element.HasAttribute("destination"))
     {
         this._destination = element.GetAttribute("destination");
     }
 }
开发者ID:spox,项目名称:irisim,代码行数:13,代码来源:Chat.cs

示例4: Initialize

 private void Initialize(XmlElement content)
 {
     XmlNodeList list = content.GetElementsByTagName("Response");
     XmlElement element = (XmlElement)list.Item(0);
     if(element.HasAttribute("type"))
     {
         this._rtype = element.GetAttribute("type");
     }
     else
     {
         this._rtype = null;
     }
 }
开发者ID:spox,项目名称:irisim,代码行数:13,代码来源:Response.cs

示例5: HashContent

 private void HashContent(XmlElement element)
 {
     if(element == null)
     {
         return;
     }
     string name = "";
     string val = "";
     XmlNodeList list = null;
     list = element.GetElementsByTagName("Value");
     foreach(XmlElement elm in list)
     {
         name = elm.GetAttribute("name");
         val = elm.InnerXml;
         this._content[name] = val;
     }
 }
开发者ID:spox,项目名称:irisim,代码行数:17,代码来源:BasicContent.cs

示例6: ParseSingleActionElement

	// this kind of message is from the opencog, and it's not a completed plan,
	// but a single action that current the robot want to do
	private void ParseSingleActionElement(XmlElement element)
	{
		OCActionController oca = GameObject.FindGameObjectWithTag("OCAGI").GetComponent<OCActionController>() as OCActionController;
		if(oca == null)
		{
			return;
		}
		
		string actionName = element.GetAttribute(OCEmbodimentXMLTags.NAME_ATTRIBUTE);
			
		if(actionName == "BuildBlockAtPosition")
		{
			int x = 0, y = 0, z = 0;
			XmlNodeList list = element.GetElementsByTagName(OCEmbodimentXMLTags.PARAMETER_ELEMENT);
			for(int i = 0; i < list.Count; i++)
			{
				XmlElement paraElement = (XmlElement)list.Item(i);
				string paraName = paraElement.GetAttribute(OCEmbodimentXMLTags.NAME_ATTRIBUTE);
				if(paraName == "x")
				{
					x = int.Parse(paraElement.GetAttribute(OCEmbodimentXMLTags.VALUE_ATTRIBUTE));
				} else if(paraName == "y")
				{
					y = int.Parse(paraElement.GetAttribute(OCEmbodimentXMLTags.VALUE_ATTRIBUTE));
				} else if(paraName == "z")
				{
					z = int.Parse(paraElement.GetAttribute(OCEmbodimentXMLTags.VALUE_ATTRIBUTE));
				}
				
			}
			Vector3i blockBuildPoint = new Vector3i(x, y, z);
			
			oca.BuildBlockAtPosition(blockBuildPoint);
		} else if(actionName == "MoveToCoordinate")
		{
			int x = 0, y = 0, z = 0;
			XmlNodeList list = element.GetElementsByTagName(OCEmbodimentXMLTags.PARAMETER_ELEMENT);
			for(int i = 0; i < list.Count; i++)
			{
				XmlElement paraElement = (XmlElement)list.Item(i);
				string paraName = paraElement.GetAttribute(OCEmbodimentXMLTags.NAME_ATTRIBUTE);
				if(paraName == "x")
				{
					x = int.Parse(paraElement.GetAttribute(OCEmbodimentXMLTags.VALUE_ATTRIBUTE));
				} else if(paraName == "y")
				{
					y = int.Parse(paraElement.GetAttribute(OCEmbodimentXMLTags.VALUE_ATTRIBUTE));
				} else if(paraName == "z")
				{
					z = int.Parse(paraElement.GetAttribute(OCEmbodimentXMLTags.VALUE_ATTRIBUTE));
				}
				
			}
			UnityEngine.Vector3 vec = new UnityEngine.Vector3(x, z, y);
			oca.MoveToCoordinate(vec);
		}
 
	}
开发者ID:Nemquae,项目名称:unity3d-opencog-game,代码行数:60,代码来源:OCConnectorSingleton.cs

示例7: ProcessPhoneNumberDescElement

        /**
        * Processes a phone number description element from the XML file and returns it as a
        * PhoneNumberDesc. If the description element is a fixed line or mobile number, the general
        * description will be used to fill in the whole element if necessary, or any components that are
        * missing. For all other types, the general description will only be used to fill in missing
        * components if the type has a partial definition. For example, if no "tollFree" element exists,
        * we assume there are no toll free numbers for that locale, and return a phone number description
        * with "NA" for both the national and possible number patterns.
        *
        * @param generalDesc  a generic phone number description that will be used to fill in missing
        *                     parts of the description
        * @param countryElement  the XML element representing all the country information
        * @param numberType  the name of the number type, corresponding to the appropriate tag in the XML
        *                    file with information about that type
        * @return  complete description of that phone number type
        */
        public static PhoneNumberDesc ProcessPhoneNumberDescElement(PhoneNumberDesc generalDesc,
            XmlElement countryElement, String numberType)
        {
            if (generalDesc == null)
                generalDesc = new PhoneNumberDesc.Builder().Build();
            var phoneNumberDescList = countryElement.GetElementsByTagName(numberType);
            var numberDesc = new PhoneNumberDesc.Builder();
            if (phoneNumberDescList.Count == 0 && !IsValidNumberType(numberType))
            {
                numberDesc.SetNationalNumberPattern("NA");
                numberDesc.SetPossibleNumberPattern("NA");
                return numberDesc.Build();
            }
            numberDesc.MergeFrom(generalDesc);
            if (phoneNumberDescList.Count > 0)
            {
                XmlElement element = (XmlElement)phoneNumberDescList[0];
                var possiblePattern = element.GetElementsByTagName(POSSIBLE_NUMBER_PATTERN);
                if (possiblePattern.Count > 0)
                    numberDesc.SetPossibleNumberPattern(ValidateRE(possiblePattern[0].InnerText, true));

                var validPattern = element.GetElementsByTagName(NATIONAL_NUMBER_PATTERN);
                if (validPattern.Count > 0)
                    numberDesc.SetNationalNumberPattern(ValidateRE(validPattern[0].InnerText, true));

                if (!LiteBuild)
                {
                    var exampleNumber = element.GetElementsByTagName(EXAMPLE_NUMBER);
                    if (exampleNumber.Count > 0)
                        numberDesc.SetExampleNumber(exampleNumber[0].InnerText);
                }
            }
            return numberDesc.Build();
        }
开发者ID:sariputra,项目名称:libphonenumber-wp7,代码行数:50,代码来源:XmlParser.cs

示例8: SetLeadingDigitsPatterns

 public static void SetLeadingDigitsPatterns(XmlElement numberFormatElement, NumberFormat.Builder format)
 {
     foreach (XmlElement e in numberFormatElement.GetElementsByTagName(LEADING_DIGITS))
     {
         format.AddLeadingDigitsPattern(ValidateRE(e.InnerText, true));
     }
 }
开发者ID:sariputra,项目名称:libphonenumber-wp7,代码行数:7,代码来源:XmlParser.cs

示例9: LoadInternationalFormat

        /**
        * Extracts the pattern for international format. If there is no intlFormat, default to using the
        * national format. If the intlFormat is set to "NA" the intlFormat should be ignored.
        *
        * @throws  RuntimeException if multiple intlFormats have been encountered.
        * @return  whether an international number format is defined.
        */
        // @VisibleForTesting
        public static bool LoadInternationalFormat(PhoneMetadata.Builder metadata,
            XmlElement numberFormatElement,
            String nationalFormat)
        {
            NumberFormat.Builder intlFormat = new NumberFormat.Builder();
            SetLeadingDigitsPatterns(numberFormatElement, intlFormat);
            intlFormat.SetPattern(numberFormatElement.GetAttribute(PATTERN));
            var intlFormatPattern = numberFormatElement.GetElementsByTagName(INTL_FORMAT);
            bool hasExplicitIntlFormatDefined = false;

            if (intlFormatPattern.Count > 1)
            {
                //LOGGER.log(Level.SEVERE,
                //          "A maximum of one intlFormat pattern for a numberFormat element should be " +
                //           "defined.");
                throw new Exception("Invalid number of intlFormat patterns for country: " +
                                    metadata.Id);
            }
            else if (intlFormatPattern.Count == 0)
            {
                // Default to use the same as the national pattern if none is defined.
                intlFormat.SetFormat(nationalFormat);
            }
            else
            {
                String intlFormatPatternValue = intlFormatPattern[0].InnerText;
                if (!intlFormatPatternValue.Equals("NA"))
                {
                    intlFormat.SetFormat(intlFormatPatternValue);
                }
                hasExplicitIntlFormatDefined = true;
            }

            if (intlFormat.HasFormat)
            {
                metadata.AddIntlNumberFormat(intlFormat);
            }
            return hasExplicitIntlFormatDefined;
        }
开发者ID:sariputra,项目名称:libphonenumber-wp7,代码行数:47,代码来源:XmlParser.cs

示例10: LoadNationalFormat

        /**
         * Extracts the pattern for the national format.
         *
         * @throws  RuntimeException if multiple or no formats have been encountered.
         * @return  the national format string.
         */
        // @VisibleForTesting
        public static String LoadNationalFormat(PhoneMetadata.Builder metadata, XmlElement numberFormatElement,
            NumberFormat.Builder format)
        {
            SetLeadingDigitsPatterns(numberFormatElement, format);
            format.SetPattern(ValidateRE(numberFormatElement.GetAttribute(PATTERN)));

            var formatPattern = numberFormatElement.GetElementsByTagName(FORMAT);
            if (formatPattern.Count != 1)
            {
                //LOGGER.log(Level.SEVERE,
                //           "Only one format pattern for a numberFormat element should be defined.");
                throw new Exception("Invalid number of format patterns for country: " +
                                    metadata.Id);
            }
            String nationalFormat = formatPattern[0].InnerText;
            format.SetFormat(nationalFormat);
            return nationalFormat;
        }
开发者ID:sariputra,项目名称:libphonenumber-wp7,代码行数:25,代码来源:XmlParser.cs

示例11: BuildPhoneMetadataCollection

 // Build the PhoneMetadataCollection from the input XML file.
 public static PhoneMetadataCollection BuildPhoneMetadataCollection(Stream input, bool liteBuild)
 {
     BuildMetadataFromXml.LiteBuild = liteBuild;
     var documentTemp = XElement.Load(input);
     var document = new XmlElement(documentTemp);
     var metadataCollection = new PhoneMetadataCollection.Builder();
     foreach (XmlElement territory in document.GetElementsByTagName("territory"))
     {
         var regionCode = territory.GetAttribute("id");
         PhoneMetadata metadata = LoadCountryMetadata(regionCode, territory);
         metadataCollection.AddMetadata(metadata);
     }
     return metadataCollection.Build();
 }
开发者ID:sariputra,项目名称:libphonenumber-wp7,代码行数:15,代码来源:XmlParser.cs

示例12: LoadAvailableFormats

        /**
        *  Extracts the available formats from the provided DOM element. If it does not contain any
        *  nationalPrefixFormattingRule, the one passed-in is retained. The nationalPrefix,
        *  nationalPrefixFormattingRule and nationalPrefixOptionalWhenFormatting values are provided from
        *  the parent (territory) element.
        */
        // @VisibleForTesting
        public static void LoadAvailableFormats(PhoneMetadata.Builder metadata, String regionCode,
            XmlElement element, String nationalPrefix,
            String nationalPrefixFormattingRule,
            bool nationalPrefixOptionalWhenFormatting)
        {
            String carrierCodeFormattingRule = "";
            if (element.HasAttribute(CARRIER_CODE_FORMATTING_RULE))
            {
                carrierCodeFormattingRule = ValidateRE(
                    GetDomesticCarrierCodeFormattingRuleFromElement(element, nationalPrefix));
            }
            var numberFormatElements = element.GetElementsByTagName(NUMBER_FORMAT);
            bool hasExplicitIntlFormatDefined = false;

            int numOfFormatElements = numberFormatElements.Count;
            if (numOfFormatElements > 0)
            {
                foreach (XmlElement numberFormatElement in numberFormatElements)
                {
                    var format = new NumberFormat.Builder();

                    if (numberFormatElement.HasAttribute(NATIONAL_PREFIX_FORMATTING_RULE))
                    {
                        format.SetNationalPrefixFormattingRule(
                            GetNationalPrefixFormattingRuleFromElement(numberFormatElement, nationalPrefix));
                        format.SetNationalPrefixOptionalWhenFormatting(
                            numberFormatElement.HasAttribute(NATIONAL_PREFIX_OPTIONAL_WHEN_FORMATTING));

                    }
                    else
                    {
                        format.SetNationalPrefixFormattingRule(nationalPrefixFormattingRule);
                        format.SetNationalPrefixOptionalWhenFormatting(nationalPrefixOptionalWhenFormatting);
                    }
                    if (numberFormatElement.HasAttribute("carrierCodeFormattingRule"))
                    {
                        format.SetDomesticCarrierCodeFormattingRule(ValidateRE(
                            GetDomesticCarrierCodeFormattingRuleFromElement(
                                numberFormatElement, nationalPrefix)));
                    }
                    else
                    {
                        format.SetDomesticCarrierCodeFormattingRule(carrierCodeFormattingRule);
                    }

                    // Extract the pattern for the national format.
                    String nationalFormat =
                        LoadNationalFormat(metadata, numberFormatElement, format);
                    metadata.AddNumberFormat(format);

                    if (LoadInternationalFormat(metadata, numberFormatElement, nationalFormat))
                    {
                        hasExplicitIntlFormatDefined = true;
                    }
                }
                // Only a small number of regions need to specify the intlFormats in the xml. For the majority
                // of countries the intlNumberFormat metadata is an exact copy of the national NumberFormat
                // metadata. To minimize the size of the metadata file, we only keep intlNumberFormats that
                // actually differ in some way to the national formats.
                if (!hasExplicitIntlFormatDefined)
                {
                    metadata.ClearIntlNumberFormat();
                }
            }
        }
开发者ID:sariputra,项目名称:libphonenumber-wp7,代码行数:72,代码来源:XmlParser.cs

示例13: GetStringValue

 private string GetStringValue(XmlElement element, string tag)
 {
     return element.GetElementsByTagName(tag)[0].InnerText;
 }
开发者ID:bartekwasielak,项目名称:BsdsApi,代码行数:4,代码来源:DataAccess.cs

示例14: checkAttributesRefSelect1

    private ImportingElement checkAttributesRefSelect1(XmlElement node)
    {
        ImportingElement importingElem = new ImportingElement();

        if (node.Attributes.GetNamedItem("appearance") != null)
            importingElem.select1Appearance = node.Attributes.GetNamedItem("appearance").Value.ToString();
        if (node.GetElementsByTagName("label").Item(0).FirstChild != null)
            importingElem.label = node.GetElementsByTagName("label").Item(0).FirstChild.Value.ToString();
        else importingElem.label = "";
        if (node.Attributes.GetNamedItem("ref") != null)
        {
            importingElem.reference = node.Attributes.GetNamedItem("ref").Value.ToString();
            importingElem.generateName();
        }
        if (node.Attributes.GetNamedItem("reflist") != null)
            importingElem.refListName = node.Attributes.GetNamedItem("reflist").Value.ToString();

        XmlNodeList itemList = node.GetElementsByTagName("item");
        Debug.WriteLine("Found " + itemList.Count + " items in select1 node");
        for (int i = 0; i < itemList.Count; i++)
        {
            XmlElement item = (XmlElement)itemList.Item(i);
            string labelValue = "";
            string itemValue = "";

            labelValue = item.GetElementsByTagName("label").Item(0).FirstChild.Value.ToString();
            itemValue = item.GetElementsByTagName("value").Item(0).FirstChild.Value.ToString();
            if (labelValue != "Select" && itemValue == "0")
                importingElem.select1Labels.Add(labelValue);
        }
        importingElem.type = "select1";
        if (node.Attributes.GetNamedItem("type") != null)
            importingElem.typeAttribute = node.Attributes.GetNamedItem("type").Value.ToString();

        return importingElem;
    }
开发者ID:WFPVAM,项目名称:GRASPReporting,代码行数:36,代码来源:ImportFormPrototype.aspx.cs

示例15: LoadOpinions

 private static Hashtable LoadOpinions(XmlElement rootElement, ArrayList impressions)
 {
     Hashtable opinions = new Hashtable();
     XmlNodeList npcNodeList = rootElement.GetElementsByTagName("npc");
     foreach (XmlElement npcElement in npcNodeList){
         string npcName = npcElement.GetAttribute("name");
         Hashtable opinionsOfNPC = new Hashtable();
         XmlNodeList opinionNodeList = npcElement.GetElementsByTagName("opinion");
         foreach (XmlElement opinionElement in opinionNodeList){
             int impressionIndex = Int32.Parse(opinionElement.GetAttribute("impression_index"));
             //Impression impression = (Impression)impressions[impressionIndex];
             string impression = (string)impressions[impressionIndex];
             opinionsOfNPC.Add(impression, new Opinion(Int32.Parse(opinionElement.GetAttribute("multiplier"))));
         }
         opinions.Add(npcName, opinionsOfNPC);
     }
     return opinions;
 }
开发者ID:kiichi7,项目名称:Lies_and_Seductions,代码行数:18,代码来源:AILoader.cs


注:本文中的XmlElement.GetElementsByTagName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。