Link to home
Start Free TrialLog in
Avatar of blue-genie
blue-genieFlag for South Africa

asked on

odd order of things being returned - not sure why - help me debug?

Hi all.
Here's my problem - excuse me for asking odd but i don't know how else to explain it.

I have this method
public ArrayList getReportPageTitles() {
ArrayList coursePageTitles = new ArrayList();

XmlNodeList courseInfoFileNameNodes = this.SelectNodes("dts/course_info/FileSet/File");
foreach (XmlNode courseInfoFileNameNode in courseInfoFileNameNodes)
{
coursePageTitles.Add(courseInfoFileNameNode.Attributes["pageName"].Value);
logger.Debug("test: " + courseInfoFileNameNode.Attributes["pageName"].Value);
}
return coursePageTitles;
}
02_Brand_Portfolio_Guidelines
assessment
03_Analysis
01_What_is_the_marketing_way

however, that same xml pulls out earlier in a course list in the right order, which is
01_
02_ ..
03_ ...
assessment

can anyone just point me in the right direction at least, cause i'm beyond stumped.
thanks.
blu.

Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Can you post a snippet of your XML that contains the nodes in question ?
Avatar of blue-genie

ASKER

i think the xml gets generated dynamically, there's no physical xml file, and i know we are using some xslt - i'll have a nosey round and see if I find anything.
i've just noticed the xml node structure is the wrong way round. so i'm guessing need to tackle where the xml gets written.
ASKER CERTIFIED SOLUTION
Avatar of LordWabbit
LordWabbit

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i've discovered this method
protected ArrayList addFileNames(XmlNode item, ArrayList fileList) {
XmlNode resource = null;
if (item.Attributes["identifierref"] != null){
resource=this.ResourcesNode.SelectSingleNode("./default:resource[@identifier=\""+item.Attributes["identifierref"].Value+"\" and @adlcp:scormtype=\"sco\" and @href]" , this.nameSpaceManager);
if (resource!=null)
{
fileList.Add(resource.Attributes["href"].Value);
}
}
else
{
//Blank item header entry needed?
XmlNodeList subList = item.SelectNodes("./default:item", this.nameSpaceManager);
foreach (XmlNode subItem in subList)
{
this.addFileNames(subItem, fileList);
}
}
return fileList;
}

and I think it's this method that's putting things into fileList wrong.

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ok, i take that back, it's doing right, back to the drawing board.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
what's sorting going to do? will it return the items alphabetically?
i've pinpointed the method that's mixing things up so i'm gonna have a nosey round there today and see what i come up with.
Yes, sorting will reutn items alphabetically
which i don't want.
okay, here's where i'm at.
System.Collections.Hashtable scoDetailsTable = courseManager.ScoDetails;
//i've checked the ScoDetails is a hashTable, and the items are in the right order
System.Collections.IDictionaryEnumerator enumerator = scoDetailsTable.GetEnumerator();

while (enumerator.MoveNext())
{

XmlNode fileNode = this.CreateNode(XmlNodeType.Element, "File", "");
fileNode.Attributes.Append(this.CreateAttribute("ident")).Value = enumerator.Key.ToString();
fileNode.Attributes.Append(this.CreateAttribute("pageName")).Value = enumerator.Value.ToString();
//this next line prints out now in the wrong order ......
System.Windows.Forms.MessageBox.Show("filenode: " +enumerator.Value.ToString());
fileSetNode.AppendChild(fileNode);
}

please please please help!!!!
blu
Pls post here the full xml (the correct order one) and I will try to reproduce/fix the problem
hi thanks, i've come to the conclusion that I can't use a hashtable so will be rewriting the code  to use an arraylist.
thanks for your efforts all.