[flexcoders] Re: Need help tranforming some XML
Well, so far no responses to this last part of my problem - but thanks very much to those of you who got me this far. I'm 90% there to the solution I need. So I'm moving this last part of my question to Flashcoders... unless someone has any idea how to solve this last part of the problem and can pipe in with an answer: --- In flexcoders@yahoogroups.com, "Jason" wrote: > > So I am almost there now, this is working, EXCEPT the code only inserts one > topic per subtopic, even though there are more 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(""); > topicx...@title = contentRowItem2.LinkTitle; > topicx...@author = stripSharepointPoundTag(contentRowItem2.Author); > topicXML.overview = new XML(); > topicXML.overview = contentRowItem2.Overview; > > var modulesList:XMLList = finalXML..module.(@title == moduleName); > > modulesList[0]..subsection.(@title==contentRowItem2.Subsection).topics > = new XML(); > > 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: > > > > > > > > > Blah blah blah > > > > > > > Blah blah blah and more blah and even more > blah > > > > > > > > > > > Blah > > > > > > > >...etc. > But only one topic appears in each subsection.topics - the last one found, not all of them found for the module and subsection. > ...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 >
[flexcoders] Re: Need help tranforming some XML
Wait - I figured out I was not adding in the node. So I am almost there now, this is working, EXCEPT the code only inserts one topic per subtopic, even though there are more 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(""); topicx...@title = contentRowItem2.LinkTitle; topicx...@author = stripSharepointPoundTag(contentRowItem2.Author); topicXML.overview = new XML(); topicXML.overview = contentRowItem2.Overview; var modulesList:XMLList = finalXML..module.(@title == moduleName); modulesList[0]..subsection.(@title==contentRowItem2.Subsection).topics = new XML(); 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: Blah blah blah Blah blah blah and more blah and even more blah Blah ...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
[flexcoders] Re: Need help tranforming some XML
>I'd include a bit of error checking for those XMLLists... > > for each (var contentRowItem:XML in _contentXML..row) > { >var moduleName:String = contentRowItem.Module; >var topicXML:XML = new XML(""); >topicx...@title = contentRowItem.LinkTitle; >var modulesList:XMLList=finalXML.module.(@title == moduleName); >if (modulesList.length()!=1) > throw new Error("Can't find single module with title:"+moduleName); > >var topicsList:XMLList= > modulesList[0]..subsection.(@title==contentRowItem.Subsection).topics; >if (topicsList.length()!=1) > throw new Error("Can't find single subsection with > title:"+contentRowItem.Subsection); > >topicsList[0].appendChild(topicXML); > } Thanks Ian, that gets me closer, but it doesn't quite work because, I get the error, "Can't find single subsection with title:Assumptions" - because not every subsection will have one with that title - that topic is only in certain subtopics. The XML it needs to be inserted into looks like this: ...etc. So there are some subsections that have one with a title of "Assumtions", but you'll see the first module's subsections doesn't have one. Trying to figure out how to account for that withouth getting null property errors. Any ideas? Thanks, you've given me some good stuff to work with so far! Jason
[flexcoders] Re: Need help tranforming some XML
--- In flexcoders@yahoogroups.com, Ian Thomas wrote: > > Oh *sigh* - mind the line breaks. > > Ian Oh, heh heh, regards to formatting, you're rerferring to YOUR post, not my original. Yeah, sucks how bad Yahoo manages to mess up formatting eh? Thanks for the post, trying it out now. Jason
[flexcoders] Re: Need help tranforming some XML
> Oh *sigh* - mind the line breaks. > > Ian Ian, I didn't insert those line breaks. I wrote this e-mail from Outlook and sent it directly to this list and it looked beautiful on the way out. I was just as disappointed with the way the formatting came out as you apparently were. Jason