Help - Kind of got it all working ...but kind of not :)
- playboxdesign
- Born


- Joined: Jun 15, 2010
- Posts: 3
- Loc: UK
- Status: Offline
This is my code (it looks rather strange but partially works) :
and my XML:
Any hints as to what i can do to tidy it up please????
Code: [ Select ]
UnitdataXML = new XML();
UnitdataXML.ignoreWhite = true;
UnitdataXML.onLoad = myLoad;
UnitdataXML.load("Moodle.xml");
function myLoad(ok) {
if (ok == true) {
Publish(this.firstChild);
}
}
function Publish(UnitdataXMLNode) {
if (UnitdataXMLNode.nodeName.toUpperCase() == "UNIT") {
content = "";
unit_info = UnitdataXMLNode.firstChild;
while (unit_info != null) {
if (unit_info.nodeName.toUpperCase() == "UNIT_INFO") {
uno = "";
uname = "";
loutcomes = "";
pass = "";
merit = "";
distinction = "";
}
element = unit_info.firstChild;
//////////////////////////////////////////////////////////////////////////
while (element != null) {
if (element.nodeName.toUpperCase() == "UNO") {
uno = element.firstChild.nodeValue;
}
if (element.nodeName.toUpperCase() == "UNAME") {
uname = element.firstChild.nodeValue;
}
if (element.nodeName.toUpperCase() == "LOUTCOMES") {
loutcomes = element.firstChild.nodeValue;
}
if (element.nodeName.toUpperCase() == "PASS") {
pass = element.firstChild.nodeValue;
}
if (element.nodeName.toUpperCase() == "MERIT") {
merit = element.firstChild.nodeValue;
}
if (element.nodeName.toUpperCase() == "DISTINCTION") {
distinction = element.firstChild.nodeValue;
}
element = element.nextSibling;
}
unit_info = unit_info.nextSibling;
//////////////////////////////////////////////////////////////////////
}
unitH_txt.htmlText = "<font size='18' color='#00CC00'>"+uno+"</font>";
unitT_txt.htmlText = "<font size='16'>"+uname+"</font>";
loutcomes = UnitdataXMLNode.firstChild.childNodes[2].childNodes;
//trace(loutcomes.length)
for (i=0; i<loutcomes.length; i++) {
var num = i+1;
var info = UnitdataXMLNode.firstChild.childNodes[2].childNodes[i].firstChild.nodeValue;
Mix += "<LI>"+info+"</LI>";
//trace("LO"+num+" = "+info+".");
}
pass = UnitdataXMLNode.firstChild.childNodes[3].childNodes;
//trace (pass.length);
for (j=0; j<pass.length; j++) {
var num = j+1;
var info2 = UnitdataXMLNode.firstChild.childNodes[3].childNodes[j].firstChild.nodeValue;
passInfo += "<LI>"+info2+"</LI>";
//trace ("P"+num+" = "+info2+".")
}
merit = UnitdataXMLNode.firstChild.childNodes[4].childNodes;
for (k=0; k<merit.length; k++) {
var num = k+1;
var info3 = UnitdataXMLNode.firstChild.childNodes[4].childNodes[k].firstChild.nodeValue;
meritInfo += "<LI>"+info3+"</LI>";
}
dist = UnitdataXMLNode.firstChild.childNodes[5].childNodes;
for (l=0; l<dist.length; l++) {
var num = l+1;
var info4 = UnitdataXMLNode.firstChild.childNodes[5].childNodes[l].firstChild.nodeValue;
distInfo += "<LI>"+info4+"</LI>";
}
LO = "<font size='12'><UL>"+Mix+"</UL></font>";
l1_txt.htmlText = LO;
}
}
UnitdataXML.ignoreWhite = true;
UnitdataXML.onLoad = myLoad;
UnitdataXML.load("Moodle.xml");
function myLoad(ok) {
if (ok == true) {
Publish(this.firstChild);
}
}
function Publish(UnitdataXMLNode) {
if (UnitdataXMLNode.nodeName.toUpperCase() == "UNIT") {
content = "";
unit_info = UnitdataXMLNode.firstChild;
while (unit_info != null) {
if (unit_info.nodeName.toUpperCase() == "UNIT_INFO") {
uno = "";
uname = "";
loutcomes = "";
pass = "";
merit = "";
distinction = "";
}
element = unit_info.firstChild;
//////////////////////////////////////////////////////////////////////////
while (element != null) {
if (element.nodeName.toUpperCase() == "UNO") {
uno = element.firstChild.nodeValue;
}
if (element.nodeName.toUpperCase() == "UNAME") {
uname = element.firstChild.nodeValue;
}
if (element.nodeName.toUpperCase() == "LOUTCOMES") {
loutcomes = element.firstChild.nodeValue;
}
if (element.nodeName.toUpperCase() == "PASS") {
pass = element.firstChild.nodeValue;
}
if (element.nodeName.toUpperCase() == "MERIT") {
merit = element.firstChild.nodeValue;
}
if (element.nodeName.toUpperCase() == "DISTINCTION") {
distinction = element.firstChild.nodeValue;
}
element = element.nextSibling;
}
unit_info = unit_info.nextSibling;
//////////////////////////////////////////////////////////////////////
}
unitH_txt.htmlText = "<font size='18' color='#00CC00'>"+uno+"</font>";
unitT_txt.htmlText = "<font size='16'>"+uname+"</font>";
loutcomes = UnitdataXMLNode.firstChild.childNodes[2].childNodes;
//trace(loutcomes.length)
for (i=0; i<loutcomes.length; i++) {
var num = i+1;
var info = UnitdataXMLNode.firstChild.childNodes[2].childNodes[i].firstChild.nodeValue;
Mix += "<LI>"+info+"</LI>";
//trace("LO"+num+" = "+info+".");
}
pass = UnitdataXMLNode.firstChild.childNodes[3].childNodes;
//trace (pass.length);
for (j=0; j<pass.length; j++) {
var num = j+1;
var info2 = UnitdataXMLNode.firstChild.childNodes[3].childNodes[j].firstChild.nodeValue;
passInfo += "<LI>"+info2+"</LI>";
//trace ("P"+num+" = "+info2+".")
}
merit = UnitdataXMLNode.firstChild.childNodes[4].childNodes;
for (k=0; k<merit.length; k++) {
var num = k+1;
var info3 = UnitdataXMLNode.firstChild.childNodes[4].childNodes[k].firstChild.nodeValue;
meritInfo += "<LI>"+info3+"</LI>";
}
dist = UnitdataXMLNode.firstChild.childNodes[5].childNodes;
for (l=0; l<dist.length; l++) {
var num = l+1;
var info4 = UnitdataXMLNode.firstChild.childNodes[5].childNodes[l].firstChild.nodeValue;
distInfo += "<LI>"+info4+"</LI>";
}
LO = "<font size='12'><UL>"+Mix+"</UL></font>";
l1_txt.htmlText = LO;
}
}
- UnitdataXML = new XML();
- UnitdataXML.ignoreWhite = true;
- UnitdataXML.onLoad = myLoad;
- UnitdataXML.load("Moodle.xml");
- function myLoad(ok) {
- if (ok == true) {
- Publish(this.firstChild);
- }
- }
- function Publish(UnitdataXMLNode) {
- if (UnitdataXMLNode.nodeName.toUpperCase() == "UNIT") {
- content = "";
- unit_info = UnitdataXMLNode.firstChild;
- while (unit_info != null) {
- if (unit_info.nodeName.toUpperCase() == "UNIT_INFO") {
- uno = "";
- uname = "";
- loutcomes = "";
- pass = "";
- merit = "";
- distinction = "";
- }
- element = unit_info.firstChild;
- //////////////////////////////////////////////////////////////////////////
- while (element != null) {
- if (element.nodeName.toUpperCase() == "UNO") {
- uno = element.firstChild.nodeValue;
- }
- if (element.nodeName.toUpperCase() == "UNAME") {
- uname = element.firstChild.nodeValue;
- }
- if (element.nodeName.toUpperCase() == "LOUTCOMES") {
- loutcomes = element.firstChild.nodeValue;
- }
- if (element.nodeName.toUpperCase() == "PASS") {
- pass = element.firstChild.nodeValue;
- }
- if (element.nodeName.toUpperCase() == "MERIT") {
- merit = element.firstChild.nodeValue;
- }
- if (element.nodeName.toUpperCase() == "DISTINCTION") {
- distinction = element.firstChild.nodeValue;
- }
- element = element.nextSibling;
- }
- unit_info = unit_info.nextSibling;
- //////////////////////////////////////////////////////////////////////
- }
- unitH_txt.htmlText = "<font size='18' color='#00CC00'>"+uno+"</font>";
- unitT_txt.htmlText = "<font size='16'>"+uname+"</font>";
- loutcomes = UnitdataXMLNode.firstChild.childNodes[2].childNodes;
- //trace(loutcomes.length)
- for (i=0; i<loutcomes.length; i++) {
- var num = i+1;
- var info = UnitdataXMLNode.firstChild.childNodes[2].childNodes[i].firstChild.nodeValue;
- Mix += "<LI>"+info+"</LI>";
- //trace("LO"+num+" = "+info+".");
- }
- pass = UnitdataXMLNode.firstChild.childNodes[3].childNodes;
- //trace (pass.length);
- for (j=0; j<pass.length; j++) {
- var num = j+1;
- var info2 = UnitdataXMLNode.firstChild.childNodes[3].childNodes[j].firstChild.nodeValue;
- passInfo += "<LI>"+info2+"</LI>";
- //trace ("P"+num+" = "+info2+".")
- }
- merit = UnitdataXMLNode.firstChild.childNodes[4].childNodes;
- for (k=0; k<merit.length; k++) {
- var num = k+1;
- var info3 = UnitdataXMLNode.firstChild.childNodes[4].childNodes[k].firstChild.nodeValue;
- meritInfo += "<LI>"+info3+"</LI>";
- }
- dist = UnitdataXMLNode.firstChild.childNodes[5].childNodes;
- for (l=0; l<dist.length; l++) {
- var num = l+1;
- var info4 = UnitdataXMLNode.firstChild.childNodes[5].childNodes[l].firstChild.nodeValue;
- distInfo += "<LI>"+info4+"</LI>";
- }
- LO = "<font size='12'><UL>"+Mix+"</UL></font>";
- l1_txt.htmlText = LO;
- }
- }
and my XML:
Code: [ Select ]
<UNIT>
<UNIT__INFO>
<UNO>Unit 8:</UNO>
<UNAME>Design and Principles in Art and Design</UNAME>
<LOUTCOMES>
<LO1>Understand how form relates to function in their own work</LO1>
<LO2>Be able to use appropriate materials in own work</LO2>
<LO3>Know how cultural associations affect their own work</LO3>
<LO4>Understand design for need and the repsonsibilities of designners</LO4>
</LOUTCOMES>
<PASS>
<P1>Explain how form relates to function in their own work</P1>
<P2>Use appropriate materials in their own design work</P2>
<P3>Explain how cultural associations affect their own work</P3>
<P4>Explain design for need and the responsibilities of the designer</P4>
</PASS>
<MERIT>
<M1>Demonstrate skills and understanding in applying aesthetic considerations to functional requirements in their finished design work</M1>
<M2>Show an effective and considered understanding of applying design principles when producing their own work</M2>
</MERIT>
<DISTINCTION>
<D1>Show an independent approach to research and the application of innovative design ideas.</D1>
<D2>Show how the evaluation undertaken in the designs stages has been applied to the development and production of exciting, coherent and individual design work.</D2>
</DISTINCTION>
</UNIT_INFO>
</UNIT>
<UNIT__INFO>
<UNO>Unit 8:</UNO>
<UNAME>Design and Principles in Art and Design</UNAME>
<LOUTCOMES>
<LO1>Understand how form relates to function in their own work</LO1>
<LO2>Be able to use appropriate materials in own work</LO2>
<LO3>Know how cultural associations affect their own work</LO3>
<LO4>Understand design for need and the repsonsibilities of designners</LO4>
</LOUTCOMES>
<PASS>
<P1>Explain how form relates to function in their own work</P1>
<P2>Use appropriate materials in their own design work</P2>
<P3>Explain how cultural associations affect their own work</P3>
<P4>Explain design for need and the responsibilities of the designer</P4>
</PASS>
<MERIT>
<M1>Demonstrate skills and understanding in applying aesthetic considerations to functional requirements in their finished design work</M1>
<M2>Show an effective and considered understanding of applying design principles when producing their own work</M2>
</MERIT>
<DISTINCTION>
<D1>Show an independent approach to research and the application of innovative design ideas.</D1>
<D2>Show how the evaluation undertaken in the designs stages has been applied to the development and production of exciting, coherent and individual design work.</D2>
</DISTINCTION>
</UNIT_INFO>
</UNIT>
- <UNIT>
- <UNIT__INFO>
- <UNO>Unit 8:</UNO>
- <UNAME>Design and Principles in Art and Design</UNAME>
- <LOUTCOMES>
- <LO1>Understand how form relates to function in their own work</LO1>
- <LO2>Be able to use appropriate materials in own work</LO2>
- <LO3>Know how cultural associations affect their own work</LO3>
- <LO4>Understand design for need and the repsonsibilities of designners</LO4>
- </LOUTCOMES>
- <PASS>
- <P1>Explain how form relates to function in their own work</P1>
- <P2>Use appropriate materials in their own design work</P2>
- <P3>Explain how cultural associations affect their own work</P3>
- <P4>Explain design for need and the responsibilities of the designer</P4>
- </PASS>
- <MERIT>
- <M1>Demonstrate skills and understanding in applying aesthetic considerations to functional requirements in their finished design work</M1>
- <M2>Show an effective and considered understanding of applying design principles when producing their own work</M2>
- </MERIT>
- <DISTINCTION>
- <D1>Show an independent approach to research and the application of innovative design ideas.</D1>
- <D2>Show how the evaluation undertaken in the designs stages has been applied to the development and production of exciting, coherent and individual design work.</D2>
- </DISTINCTION>
- </UNIT_INFO>
- </UNIT>
Any hints as to what i can do to tidy it up please????
Attachments:
Attachments:
- Anonymous
- Bot


- Joined: 25 Feb 2008
- Posts: ?
- Loc: Ozzuland
- Status: Online
June 15th, 2010, 3:12 am
- graphixboy
- Control + Z


- Joined: Jul 11, 2005
- Posts: 1828
- Loc: In the Great White North
- Status: Offline
- playboxdesign
- Born


- Joined: Jun 15, 2010
- Posts: 3
- Loc: UK
- Status: Offline
It is the 'undefined' when you press the P M and D buttons. The information comes up but I think it is the main node ie the
Pass node - that is undefined
where as the 4 nodes inside there are ok.
I have kind of hacked together bits of code from a couple of tutorials.
I really did not want it 'hard coded', I wanted to load the xml and loop through the nodes, child nodes and their child nodes using the .length etc
So I want 3 nested loops - but getting myself so confused with the syntax for the nodes. I would like some really tidy non hard coded code. I was going to start off in Pseudo code to try and work it all out from there... kind of lost a bit of steam at moment, it was making my head hurt
Pass node - that is undefined
where as the 4 nodes inside there are ok.
I have kind of hacked together bits of code from a couple of tutorials.
I really did not want it 'hard coded', I wanted to load the xml and loop through the nodes, child nodes and their child nodes using the .length etc
So I want 3 nested loops - but getting myself so confused with the syntax for the nodes. I would like some really tidy non hard coded code. I was going to start off in Pseudo code to try and work it all out from there... kind of lost a bit of steam at moment, it was making my head hurt
Page 1 of 1
To Reply to this topic you need to LOGIN or REGISTER. It is free.
Post Information
- Total Posts in this topic: 4 posts
- Users browsing this forum: No registered users and 51 guests
- You cannot post new topics in this forum
- You cannot reply to topics in this forum
- You cannot edit your posts in this forum
- You cannot delete your posts in this forum
- You cannot post attachments in this forum
