本文整理汇总了C#中XmlElement.GetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# XmlElement.GetAttribute方法的具体用法?C# XmlElement.GetAttribute怎么用?C# XmlElement.GetAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlElement
的用法示例。
在下文中一共展示了XmlElement.GetAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseElement
public override void ParseElement(XmlElement element)
{
string tmpArgVal = "";
tmpArgVal = element.GetAttribute("type");
if (!string.IsNullOrEmpty(tmpArgVal))
{
if (tmpArgVal.Equals("none"))
transition.setType(Transition.TYPE_NONE);
else if (tmpArgVal.Equals("fadein"))
transition.setType(Transition.TYPE_FADEIN);
else if (tmpArgVal.Equals("vertical"))
transition.setType(Transition.TYPE_VERTICAL);
else if (tmpArgVal.Equals("horizontal"))
transition.setType(Transition.TYPE_HORIZONTAL);
}
tmpArgVal = element.GetAttribute("time");
if (!string.IsNullOrEmpty(tmpArgVal))
{
transition.setTime(long.Parse(tmpArgVal));
}
animation.getTransitions().Add(transition);
}
示例2: Rot
//! initializes from passed-in xml element, in format <someelement x="..." y="..." z="..." s="..."/>
public Rot( XmlElement xmlelement )
{
x = Convert.ToDouble( xmlelement.GetAttribute( "x" ) );
y = Convert.ToDouble( xmlelement.GetAttribute( "y" ) );
z = Convert.ToDouble( xmlelement.GetAttribute( "z" ) );
s = Convert.ToDouble( xmlelement.GetAttribute( "s" ) );
}
示例3: loadNode
private static DialogNode loadNode(XmlElement xmlEl,
ref Conversation conversation,
ref List<DialogResponse> respWithoutChildren,
ref List<DialogResponse> respThatSwitchConv)
{
string id = xmlEl.GetAttribute("id");
string npcPhrase = xmlEl.GetAttribute("npcPhrase");
//string voiceFile = xmlEl.GetAttribute("voiceFile");
DialogNode node = new DialogNode(id, npcPhrase);
XmlNodeList responsesXNL = xmlEl.ChildNodes;
for (int j = 0; j < responsesXNL.Count; j++)
{
XmlElement responseXE = (XmlElement)responsesXNL[j];
string pcPhrase = responseXE.GetAttribute("pcPhrase");
string link = responseXE.GetAttribute("link");
ResponseLinkType linkType = ResponseLinkType.dialogNode;
if (responseXE.GetAttribute("linkType").
Equals("dialogNode"))
linkType = ResponseLinkType.dialogNode;
else if (responseXE.GetAttribute("linkType").
Equals("endConversation"))
linkType = ResponseLinkType.endConversation;
else
linkType = ResponseLinkType.endAndChangeConversation;
string switchConv = responseXE.
GetAttribute("switchConversation");
bool onlyAllowOnce = bool.Parse(responseXE.
GetAttribute("onlyAllowOnce"));
DialogResponse response = new DialogResponse(pcPhrase, link,
onlyAllowOnce, linkType, switchConv);
node.addResponse(response);
if (responseXE.HasChildNodes)
{
XmlElement childNode = (XmlElement)responseXE.FirstChild;
DialogNode dn = loadNode(childNode, ref conversation,
ref respWithoutChildren, ref respThatSwitchConv);
response.childNode = dn;
conversation.addDialogNode(dn);
}
else if (linkType == ResponseLinkType.dialogNode)
respWithoutChildren.Add(response);
if (linkType == ResponseLinkType.endAndChangeConversation)
respThatSwitchConv.Add(response);
}
return node;
}
示例4: 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;
}
示例5: ParseElement
public override void ParseElement(XmlElement element)
{
XmlNodeList
conditions = element.SelectNodes("condition");
string tmpArgVal;
int x = 0, y = 0, width = 0, height = 0;
tmpArgVal = element.GetAttribute("x");
if (!string.IsNullOrEmpty(tmpArgVal))
{
x = int.Parse(tmpArgVal);
}
tmpArgVal = element.GetAttribute("y");
if (!string.IsNullOrEmpty(tmpArgVal))
{
y = int.Parse(tmpArgVal);
}
tmpArgVal = element.GetAttribute("width");
if (!string.IsNullOrEmpty(tmpArgVal))
{
width = int.Parse(tmpArgVal);
}
tmpArgVal = element.GetAttribute("height");
if (!string.IsNullOrEmpty(tmpArgVal))
{
height = int.Parse(tmpArgVal);
}
barrier = new Barrier(generateId(), x, y, width, height);
if (element.SelectSingleNode("documentation") != null)
barrier.setDocumentation(element.SelectSingleNode("documentation").InnerText);
foreach (XmlElement ell in conditions)
{
currentConditions = new Conditions();
new ConditionSubParser_(currentConditions, chapter).ParseElement(ell);
this.barrier.setConditions(currentConditions);
}
scene.addBarrier(barrier);
}
示例6: DeserializeElement
public IUnitTestElement DeserializeElement(XmlElement parent, IUnitTestElement parentElement)
{
if (!parent.HasAttribute("type"))
throw new ArgumentException("Element has no Type attribute");
ReadFromXmlFunc func;
if (DeserialiseMap.TryGetValue(parent.GetAttribute("type"), out func))
return func(parent, parentElement, _solution, _unitTestElementFactory);
throw new ArgumentException("Element has no Type attribute");
}
示例7: AbstractLine
public AbstractLine(XmlElement element, LineCatalogue catalogue, Conversation conversation)
{
responses = new ArrayList();
int lineId = Int32.Parse(element.GetAttribute("id"));
catalogue.AddLine(lineId, this);
string responseSpeakerTypeString = element.GetAttribute("response_speaker_type");
if (responseSpeakerTypeString.Equals("PC")){
responseSpeakerType = SpeakerType.PC;
} else if (responseSpeakerTypeString.Equals("NPC")){
responseSpeakerType = SpeakerType.NPC;
}
XmlNodeList nodeList = element.ChildNodes;
for (int i = 0; i < nodeList.Count; i++){
XmlElement responseElement = (XmlElement)nodeList.Item(i);
//Debug.Log("AbstractLine.AbstractLine(): responceElement=" + responseElement.ToString());
if (responseElement.Name.Equals("regular_line")){
responses.Add(new RegularLine(responseElement, catalogue, conversation));
} else {
responses.Add(new Link(responseElement, catalogue));
}
}
haveConnectedLinks = false;
}
示例8: RegularLine
public RegularLine(XmlElement element, LineCatalogue catalogue, Conversation conversation)
: base(element, catalogue, conversation)
{
text = element.GetAttribute("text");
speakerName = element.GetAttribute("speaker");
if (speakerName.Equals("")){
speakerName = "Abby";
}
prerequisite = new Prerequisite(element.GetAttribute("prerequisite"), speakerName, conversation);
consequence = new Consequence(element.GetAttribute("consequence"), speakerName, conversation);
cameraAngle = CameraAngle.GetCameraAngle(element.GetAttribute("camera_angle"));
emotion = Emotion.GetEmotion(element.GetAttribute("expression"));
id = element.GetAttribute("id");
}
示例9: parse
public void parse(XmlElement xmlElement)
{
string tmpStr;
string[] tmpStrs;
int i;
this.id = xmlElement.GetAttribute("Id");
this.name = xmlElement.GetAttribute("Name");
this.description = xmlElement.GetAttribute("Description");
this.type = xmlElement.GetAttribute("Type");
this.hitPoint = int.Parse(xmlElement.GetAttribute("HitPoint"));
this.mobilityBase = int.Parse(xmlElement.GetAttribute("Mobility"));
this.attackBase = int.Parse(xmlElement.GetAttribute("AttackPower"));
//this.defenceBase = int.Parse(xmlElement.GetAttribute("Defence"));
string range = xmlElement.GetAttribute("AttackRange");
string[] rangeList = range.Split(',');
if ( rangeList.Length == 1 )
{
this.minAttackRange = 0;
this.maxAttackRange = int.Parse(rangeList[0]);
}
else
{
this.minAttackRange = int.Parse(rangeList[0]);
this.maxAttackRange = int.Parse(rangeList[1]);
}
tmpStr = xmlElement.GetAttribute("isEnable");
isEnable = tmpStr == "" ? 0 : int.Parse(tmpStr);
this.cardTexture = xmlElement.GetAttribute("CardTexture");
this.characterTexture = xmlElement.GetAttribute("CharacterTexture");
if ( this.characterTexture == "" )
{
this.characterTexture = "Unit_1";
}
// 技能
tmpStr = xmlElement.GetAttribute("Skills");
tmpStrs = tmpStr.Split(',');
List<string> strList = new List<string>();
for (i=0;i<tmpStrs.Length;i++)
{
if ( tmpStrs[i] != "" )
{
strList.Add(tmpStrs[i]);
}
}
this.skillIds = strList.ToArray();
}
示例10: LoadTerritoryTagMetadata
public static PhoneMetadata.Builder LoadTerritoryTagMetadata(String regionCode, XmlElement element,
String nationalPrefix,
String nationalPrefixFormattingRule)
{
var metadata = new PhoneMetadata.Builder();
metadata.SetId(regionCode);
metadata.SetCountryCode(int.Parse(element.GetAttribute(COUNTRY_CODE)));
if (element.HasAttribute(LEADING_DIGITS))
metadata.SetLeadingDigits(ValidateRE(element.GetAttribute(LEADING_DIGITS)));
metadata.SetInternationalPrefix(ValidateRE(element.GetAttribute(INTERNATIONAL_PREFIX)));
if (element.HasAttribute(PREFERRED_INTERNATIONAL_PREFIX))
{
String preferredInternationalPrefix = element.GetAttribute(PREFERRED_INTERNATIONAL_PREFIX);
metadata.SetPreferredInternationalPrefix(preferredInternationalPrefix);
}
if (element.HasAttribute(NATIONAL_PREFIX_FOR_PARSING))
{
metadata.SetNationalPrefixForParsing(
ValidateRE(element.GetAttribute(NATIONAL_PREFIX_FOR_PARSING)));
if (element.HasAttribute(NATIONAL_PREFIX_TRANSFORM_RULE))
{
metadata.SetNationalPrefixTransformRule(
ValidateRE(element.GetAttribute(NATIONAL_PREFIX_TRANSFORM_RULE)));
}
}
if (!String.IsNullOrEmpty(nationalPrefix))
{
metadata.SetNationalPrefix(nationalPrefix);
if (!metadata.HasNationalPrefixForParsing)
metadata.SetNationalPrefixForParsing(nationalPrefix);
}
if (element.HasAttribute(PREFERRED_EXTN_PREFIX))
{
metadata.SetPreferredExtnPrefix(element.GetAttribute(PREFERRED_EXTN_PREFIX));
}
if (element.HasAttribute(MAIN_COUNTRY_FOR_CODE))
{
metadata.SetMainCountryForCode(true);
}
if (element.HasAttribute(LEADING_ZERO_POSSIBLE))
{
metadata.SetLeadingZeroPossible(true);
}
return metadata;
}
示例11: 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);
}
}
示例12: ParsePsiDemandElement
private void ParsePsiDemandElement(XmlElement element)
{
string avatarId = element.GetAttribute(OCEmbodimentXMLTags.ENTITY_ID_ATTRIBUTE);
// Parse all demands and add them to a map.
XmlNodeList list = element.GetElementsByTagName(OCEmbodimentXMLTags.DEMAND_ELEMENT);
for(int i = 0; i < list.Count; i++)
{
XmlElement demandElement = (XmlElement)list.Item(i);
string demand = demandElement.GetAttribute(OCEmbodimentXMLTags.NAME_ATTRIBUTE);
float value = float.Parse(demandElement.GetAttribute(OCEmbodimentXMLTags.VALUE_ATTRIBUTE));
// group all demands to be updated only once
_demandValueMap[demand] = value;
OCLogger.Debugging("Avatar[" + _ID + "] -> parsePsiDemandElement: Demand '" + demand + "' value '" + value + "'.");
}
}
示例13: ParseElement
public override void ParseElement(XmlElement element)
{
XmlNodeList speakschar,
speaksplayer,
childs,
effects,
conditions;
XmlNode end_conversation;
string tmpArgVal;
// Store the name
conversationName = "";
tmpArgVal = element.GetAttribute("id");
if (!string.IsNullOrEmpty(tmpArgVal))
{
conversationName = tmpArgVal;
}
graphNodes = new List<ConversationNode>();
nodeLinks = new List<List<int>>();
foreach (XmlElement el in element) {
if (el.Name == "dialogue-node") {
// Create the node depending of the tag
editorX = editorY = int.MinValue;
//If there is a "waitUserInteraction" attribute, store if the lines will wait until user interacts
tmpArgVal = element.GetAttribute ("keepShowing");
if (!string.IsNullOrEmpty (tmpArgVal)) {
if (tmpArgVal.Equals ("yes"))
keepShowingDialogue = true;
else
keepShowingDialogue = false;
}
//If there is a "editor-x" and "editor-y" attributes
tmpArgVal = element.GetAttribute ("editor-x");
if (!string.IsNullOrEmpty (tmpArgVal)) {
editorX = Mathf.Max (0, int.Parse (tmpArgVal));
}
tmpArgVal = element.GetAttribute ("editor-y");
if (!string.IsNullOrEmpty (tmpArgVal)) {
editorY = Mathf.Max (0, int.Parse (tmpArgVal));
}
currentNode = new DialogueConversationNode (keepShowingDialogue);
if (editorX > int.MinValue) {
currentNode.setEditorX (editorX);
}
if (editorY > int.MinValue) {
currentNode.setEditorY (editorY);
}
// Create a new vector for the links of the current node
currentLinks = new List<int> ();
parseLines (currentNode, el);
end_conversation = el.SelectSingleNode ("end-conversation");
if (end_conversation != null)
effects = end_conversation.SelectNodes ("effect");
else
effects = el.SelectNodes ("effect");
foreach (XmlElement ell in effects) {
currentEffects = new Effects ();
new EffectSubParser_ (currentEffects, chapter).ParseElement (ell);
currentNode.setEffects (currentEffects);
}
// Add the current node to the node list, and the set of children references into the node links
graphNodes.Add (currentNode);
nodeLinks.Add (currentLinks);
} else if (el.Name == "option-node") {
editorX = editorY = int.MinValue;
//If there is a "waitUserInteraction" attribute, store if the lines will wait until user interacts
tmpArgVal = element.GetAttribute ("keepShowing");
if (!string.IsNullOrEmpty (tmpArgVal)) {
if (tmpArgVal.Equals ("yes"))
keepShowingDialogue = true;
else
keepShowingDialogue = false;
}
//If there is a "editor-x" and "editor-y" attributes
tmpArgVal = element.GetAttribute ("editor-x");
if (!string.IsNullOrEmpty (tmpArgVal)) {
editorX = Mathf.Max (0, int.Parse (tmpArgVal));
}
tmpArgVal = element.GetAttribute ("editor-y");
if (!string.IsNullOrEmpty (tmpArgVal)) {
editorY = Mathf.Max (0, int.Parse (tmpArgVal));
}
tmpArgVal = element.GetAttribute ("random");
//.........这里部分代码省略.........
示例14: GetInt
int GetInt(XmlElement xmlelement, string attributename)
{
try
{
int value = Convert.ToInt32(xmlelement.GetAttribute(attributename));
return value;
}
catch
{
EmergencyDialog.WarningMessage("In the config.xml file, the value " + attributename + " in section " + xmlelement.Name + " needs to be a whole number. MapDesigner may not run correctly.");
return 0;
}
}
示例15: ParseElement
public override void ParseElement(XmlElement element)
{
XmlNodeList
speakschar = element.SelectNodes("speak-char"),
speaksplayer = element.SelectNodes("speak-player"),
responses = element.SelectNodes("response"),
options = element.SelectNodes("option"),
effects = element.SelectNodes("effect"),
gosback = element.SelectNodes("go-back");
string tmpArgVal;
// Store the name
string conversationName = "";
tmpArgVal = element.GetAttribute("id");
if (!string.IsNullOrEmpty(tmpArgVal))
{
conversationName = tmpArgVal;
}
// Create a dialogue node (which will be the root node) and add it to a new tree
// The content of the tree will be built adding nodes directly to the root
currentNode = new DialogueConversationNode();
conversation = new TreeConversation(conversationName, currentNode);
pastOptionNodes = new List<ConversationNode>();
foreach (XmlElement el in speakschar)
{
// Set default name to "NPC"
characterName = "NPC";
audioPath = "";
// If there is a "idTarget" attribute, store it
tmpArgVal = el.GetAttribute("idTarget");
if (!string.IsNullOrEmpty(tmpArgVal))
{
characterName = tmpArgVal;
}
// If there is a "uri" attribute, store it as audio path
tmpArgVal = el.GetAttribute("uri");
if (!string.IsNullOrEmpty(tmpArgVal))
{
audioPath = tmpArgVal;
}
// If there is a "uri" attribute, store it as audio path
tmpArgVal = el.GetAttribute("synthesize");
if (!string.IsNullOrEmpty(tmpArgVal))
{
string response = tmpArgVal;
if (response.Equals("yes"))
synthesizerVoice = true;
else
synthesizerVoice = false;
}
// Store the read string into the current node, and then delete the string. The trim is performed so we
// don't
// have to worry with indentations or leading/trailing spaces
ConversationLine line = new ConversationLine(characterName, el.InnerText);
if (audioPath != null && !this.audioPath.Equals(""))
{
line.setAudioPath(audioPath);
}
if (synthesizerVoice != null)
line.setSynthesizerVoice(synthesizerVoice);
currentNode.addLine(line);
}
foreach (XmlElement el in speaksplayer)
{
audioPath = "";
// If there is a "uri" attribute, store it as audio path
tmpArgVal = el.GetAttribute("uri");
if (!string.IsNullOrEmpty(tmpArgVal))
{
audioPath = tmpArgVal;
}
// If there is a "uri" attribute, store it as audio path
tmpArgVal = el.GetAttribute("synthesize");
if (!string.IsNullOrEmpty(tmpArgVal))
{
string response = tmpArgVal;
if (response.Equals("yes"))
synthesizerVoice = true;
else
synthesizerVoice = false;
}
// Store the read string into the current node, and then delete the string. The trim is performed so we
// don't have to worry with indentations or leading/trailing spaces
ConversationLine line = new ConversationLine(ConversationLine.PLAYER, el.InnerText);
if (audioPath != null && !this.audioPath.Equals(""))
{
line.setAudioPath(audioPath);
//.........这里部分代码省略.........