blue-genie
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/cour se_info/Fi leSet/File ");
foreach (XmlNode courseInfoFileNameNode in courseInfoFileNameNodes)
{
coursePageTitles.Add(cours eInfoFileN ameNode.At tributes[" pageName"] .Value);
logger.Debug("test: " + courseInfoFileNameNode.Att ributes["p ageName"]. Value);
}
return coursePageTitles;
}
02_Brand_Portfolio_Guideli nes
assessment
03_Analysis
01_What_is_the_marketing_w ay
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.
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/cour
foreach (XmlNode courseInfoFileNameNode in courseInfoFileNameNodes)
{
coursePageTitles.Add(cours
logger.Debug("test: " + courseInfoFileNameNode.Att
}
return coursePageTitles;
}
02_Brand_Portfolio_Guideli
assessment
03_Analysis
01_What_is_the_marketing_w
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.
Can you post a snippet of your XML that contains the nodes in question ?
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.
ASKER
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i've discovered this method
protected ArrayList addFileNames(XmlNode item, ArrayList fileList) {
XmlNode resource = null;
if (item.Attributes["identifi erref"] != null){
resource=this.ResourcesNod e.SelectSi ngleNode(" ./default: resource[@ identifier =\""+item. Attributes ["identifi erref"].Va lue+"\" and @adlcp:scormtype=\"sco\" and @href]" , this.nameSpaceManager);
if (resource!=null)
{
fileList.Add(resource.Attr ibutes["hr ef"].Value );
}
}
else
{
//Blank item header entry needed?
XmlNodeList subList = item.SelectNodes("./defaul t: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.
protected ArrayList addFileNames(XmlNode item, ArrayList fileList) {
XmlNode resource = null;
if (item.Attributes["identifi
resource=this.ResourcesNod
if (resource!=null)
{
fileList.Add(resource.Attr
}
}
else
{
//Blank item header entry needed?
XmlNodeList subList = item.SelectNodes("./defaul
foreach (XmlNode subItem in subList)
{
this.addFileNames(subItem,
}
}
return fileList;
}
and I think it's this method that's putting things into fileList wrong.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok, i take that back, it's doing right, back to the drawing board.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
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
ASKER
which i don't want.
okay, here's where i'm at.
System.Collections.Hashtab le scoDetailsTable = courseManager.ScoDetails;
//i've checked the ScoDetails is a hashTable, and the items are in the right order
System.Collections.IDictio naryEnumer ator enumerator = scoDetailsTable.GetEnumera tor();
while (enumerator.MoveNext())
{
XmlNode fileNode = this.CreateNode(XmlNodeTyp e.Element, "File", "");
fileNode.Attributes.Append (this.Crea teAttribut e("ident") ).Value = enumerator.Key.ToString();
fileNode.Attributes.Append (this.Crea teAttribut e("pageNam e")).Value = enumerator.Value.ToString( );
//this next line prints out now in the wrong order ......
System.Windows.Forms.Messa geBox.Show ("filenode : " +enumerator.Value.ToString ());
fileSetNode.AppendChild(fi leNode);
}
please please please help!!!!
blu
okay, here's where i'm at.
System.Collections.Hashtab
//i've checked the ScoDetails is a hashTable, and the items are in the right order
System.Collections.IDictio
while (enumerator.MoveNext())
{
XmlNode fileNode = this.CreateNode(XmlNodeTyp
fileNode.Attributes.Append
fileNode.Attributes.Append
//this next line prints out now in the wrong order ......
System.Windows.Forms.Messa
fileSetNode.AppendChild(fi
}
please please please help!!!!
blu
Pls post here the full xml (the correct order one) and I will try to reproduce/fix the problem
ASKER
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.
thanks for your efforts all.