- Home /
How Load XML File in java?
Hi..
I have this XML File:
<Question Text="What is the common name for ascorbic acid ?">
<Answer Text="Vitamin C" Correct="True"></Answer>
<Answer Text="Vitamin A" Correct="False"></Answer>
<Answer Text="Vitamin B" Correct="False"></Answer>
<Answer Text="Vitamin D" Correct="False"></Answer>
</Question>
it's contain a 2 question and 4 answers for every one , how can I load the first question and the answers ??
please JAVA Code How can I Load from XML File
Answer by YikYikHeiHei · Aug 13, 2011 at 02:45 AM
I have to use this script to read xml in unity! And it is Unity JavaScript!
var XMLFile : TextAsset;
function Start ()
{
if(XMLFile != null)
{
var reader:XmlTextReader = new XmlTextReader(new StringReader(XMLFile.text));
while(reader.Read())
{
if(reader.Name == "Answer")
{
Debug.Log(reader.Name + "Text = " + reader.GetAttribute("Text") + " " + "Correct = " + reader.GetAttribute("Correct"));
}
}
}
}
This is great! All that I have found on loading xml this way was using c#. As you might have noticed there are a few more hoops to jump through to use js. Thank you!
Answer by MrSplosion · Aug 12, 2011 at 09:16 PM
This might help you out: http://www.unifycommunity.com/wiki/index.php?title=Save_and_Load_from_XML
Your answer
Follow this Question
Related Questions
Load XML File ? 1 Answer
My Js Script is not working 1 Answer
Saving/Loading Vertices Efficiently 2 Answers
A node in a childnode? 1 Answer