I I’m trying to find a way to access the “class” attribute of a single character and modify it. So far, I have reached the point where I can pinpoint a specific character, but I can’t figure out how to access the’Class’ attribute and modify it for char It.
void Write(string path, string charName, string varToChange, string value){
XmlNode curNode = null;
XmlDocument doc = new XmlDocument();
doc.Load(path);
XmlElement rootDoc = doc.DocumentElement;
curNode = rootDoc;
if (curNode.HasChildNodes){
for(int i=0; i
if(charName == curNode.ChildNodes[i ].Attributes.GetNamedItem("Name").Value){
// Code would go here
}
}
}
return;< br />}
doc.Load(path);
var nodes = doc.SelectNodes(String.Format(“/Team/Character[@Name=\ “{0}\”]”, charName));
foreach (XmlElement n in nodes)
{
n.SetAttribute(varToChange, value);
}
I have written the XML document very well, it will look like this
I’m trying to find a way to access the “class” attribute of a single character and modify it. So far, I have reached the point where I can pinpoint a specific character, but I can’t figure out how to access the’Class’ Attribute and modify it for char.
void Write(string path, string charName, string varToChange, string value){
XmlNode curNode = null;
XmlDocument doc = new XmlDocument();
doc.Load(path);
XmlElement rootDoc = doc.DocumentElement;
curNode = rootDoc;
if(curNode.HasChildNodes){
for(int i=0; i
if(charName == curNode.ChildNodes[i].Attribut es.GetNamedItem("Name").Value){
// Code would go here
}
}
}
return;
}
Use XPATH:
XmlDocument doc = new XmlDocument();
doc.Load(path);
var nodes = doc.SelectNodes(String.Format("/Team/Character[@Name=\"{0}\"]", charName)) ;
foreach (XmlElement n in nodes)
{
n.SetAttribute(varToChange, value);
}