Home Unity

[C# Scripting] - xml

Abduzeedo
null
Hi.

I have a xml script but I can't get all values from xml file. What is it wrong ?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using System.IO;
using System.Xml;
using UnityEngine.UI;

public class readXML : MonoBehaviour {

public Text uiText;

// Use this for initialization
void Start () {
string totVal = "";
XmlDocument xmlDoc = new XmlDocument ();

xmlDoc.LoadXml ("<book ISBN='1-861001-57-5'>" +
"<title>Pride And Prejudice</title>" +
"<price>10.00</price>" +
"<title>Pride And Prejudice</title>" +
"<price>20.00</price>" +
"</book>");

string xmlPathPattern = "//book";
XmlNodeList myNodeList = xmlDoc.SelectNodes (xmlPathPattern);
foreach (XmlNode node in myNodeList) {
XmlNode title = node.FirstChild;
XmlNode price = title.NextSibling;

totVal += " Title : " + title.InnerXml + "\n Price : " + price.InnerXml + "\n\n";
uiText.text = totVal;
}

}
}


Thank You

Replies

Sign In or Register to comment.