Wait - I figured out I was not adding in the <topics /> node. So I am almost
there now, this is working, EXCEPT the code only inserts one topic per
subtopic, even though there are more <row> nodes that are tagged to the same
subtopic in the same module. If more than one topic belongs to a topics node,
it gets overwritten, so only the last one found is inserted. The code as I have
it now (thanks Ian) is:
for each (var contentRowItem2:XML in _contentXML..row)
{
var moduleName:String = stripSharepointPoundTag(contentRowItem2.Module);
var topicXML:XML = new XML("<topic />");
topicx...@title = contentRowItem2.LinkTitle;
topicx...@author = stripSharepointPoundTag(contentRowItem2.Author);
topicXML.overview = new XML(<overview />);
topicXML.overview = contentRowItem2.Overview;
var modulesList:XMLList = finalXML..module.(@title == moduleName);
modulesList[0]..subsection.(@title==contentRowItem2.Subsection).topics
= new XML(<topics />);
if (modulesList.length()!= 1)
throw new Error("Can't find single module with title:"+moduleName);
var topicsList:XMLList =
modulesList[0]..subsection.(@title==contentRowItem2.Subsection).topics;
if (topicsList.length()!=1)
throw new Error("Can't find single subsection with
title:"+contentRowItem.Subsection);
topicsList[0].appendChild(topicXML);
}
This produces this:
<xml>
<modules>
<module title="iRequire" orderID="0">
<subsections>
<subsection title="Technical Constraints">
<topics>
<topic title="Test Topic 1" author="Markley, Bill">
<Overview>Blah blah blah</Overview>
</topic>
</topics>
</subsection>
<subsection title="Project Information">
<topics>
<topic title="Test Topic 3" author="Merrill, Jason">
<Overview>Blah blah blah and more blah and even more
blah</Overview>
</topic>
</topics>
</subsection>
</subsections>
</module>
<module title="iDesign" orderID="1.00000000000000">
<subsections>
<subsection title="Assumptions">
<topics>
<topic title="Test Topic 15" author="Merrill, Jason">
<Overview>Blah</Overview>
</topic>
</topics>
</subsection>
</subsections>
</module>
<module title="iBuild" orderID="2.00000000000000">
<subsections>
...etc.
So the line, topicsList[0].appendChild(topicXML); is suspect, but wouldn't
appendChild just add a new child, not overwrite the existing child? Thanks for
any help,
Jason