Code |
How do I read the score from this file later? I think I've tried on million times with different ways and I still can't figure this out. I was trying for example with this code:
Java |
but it didn't work. Please help.
Code |
Java |
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
CrishRank #1,487 · 1.1K reputationPosted May 19, 2010, 8:56 AM EDT
try this link http://www.stardeveloper.com/articles/display.html?article=2009030701&page=1
also , plese try below code
private void btnLoad_Click(object sender, System.EventArgs e) { XmlTextReader reader = new XmlTextReader( Server.MapPath("mycompany.xml")); reader.WhitespaceHandling = WhitespaceHandling.None; XmlDocument xmlDoc = new XmlDocument(); //Load the file into the XmlDocument xmlDoc.Load(reader); //Close off the connection to the file. reader.Close(); //Add and item representing the document to the listbox lbNodes.Items.Add("XML Document"); //Find the root nede, and add it togather with its childeren XmlNode xnod = xmlDoc.DocumentElement; AddWithChildren(xnod,1); } private void AddWithChildren(XmlNode xnod, Int32 intLevel) { //Adds a node to the ListBox, togather with its children. //intLevel controls the depth of indenting XmlNode xnodWorking; String strIndent = new string(' ',2 * intLevel); //Get the value of the node (if any) string strValue = (string) xnod.Value; if(strValue != null) { strValue = " : " + strValue; } //Add the node details to the ListBox lbNodes.Items.Add(strIndent + xnod.Name + strValue); //For an element node, retrive the attributes if (xnod.NodeType == XmlNodeType.Element) { XmlNamedNodeMap mapAttributes = xnod.Attributes; //Add the attributes to the ListBox foreach(XmlNode xnodAttribute in mapAttributes) { lbNodes.Items.Add(strIndent + " " + xnodAttribute.Name + " : " + xnodAttribute.Value); } //If there are any child node, call this procedrue recursively if(xnod.HasChildNodes) { xnodWorking = xnod.FirstChild; while (xnodWorking != null) { AddWithChildren(xnodWorking, intLevel +1); xnodWorking = xnodWorking.NextSibling; } } } } }Simon3 reputationPosted May 19, 2010, 9:32 AM EDT
System.Xml.XmlDocument xd = new XmlDocument();
xd.Load("Decrypted.xml");
XmlNode root = xd.DocumentElement;
temp = root.SelectSingleNode("HighestScore").ChildNodes[0].Value;
bestResult = Int32.Parse(temp);
Thank you :)