error in my xml output

I have a problem. I am getting an error when I have my app export create and export xml. I think its something that will be obvious to a more talented person. I just can’t figure it out.

This is the error I am getting

2013-04-23 08:24:24.847 MyXML[8375:303] -[__NSCFString parent]: unrecognized selector sent to instance 0x4034f4240
2013-04-23 08:24:24.848 MyXML[8375:303] *** -[CMSA_XMLAppDelegate testExtractXML:]: -[__NSCFString parent]: unrecognized selector sent to instance 0x4034f4240 (error -10000)

set jobsNode to (current application's NSXMLNode's elementWithName_("JOBS"))
			set theDoc to current application's NSXMLNode's documentWithRootElement_(jobsNode)
			tell theDoc
				setVersion_("1.0")
				setCharacterEncoding_("UTF-8")
			end tell
			
            set jobNode to (current application's NSXMLNode's elementWithName_("CreateJobParameters"))
			set XMLOrderID to (orderID's stringValue() as string)
            jobNode's addChild_(XMLOrderID)
            set pressSheetNode to (current application's NSXMLNode's elementWithName_stringValue_("pressSheet", (pressSheet's stringValue() as string)))
			jobNode's addChild_(pressSheetNode)
            set prodOrderNode to (current application's NSXMLNode's elementWithName_stringValue_("prodOrder", (prodOrder's stringValue() as string)))
			jobNode's addChild_(prodOrderNode)
            set printMethodNode to (current application's NSXMLNode's elementWithName_stringValue_("printMethod", (printMethod's titleOfSelectedItem() as string)))
			jobNode's addChild_(printMethodNode)
            set finishMethodNode to (current application's NSXMLNode's elementWithName_stringValue_("finishMethod", (finishMethod's titleOfSelectedItem() as string)))
			jobNode's addChild_(finishMethodNode)
            set grainDirectionNode to (current application's NSXMLNode's elementWithName_stringValue_("grainDirection", (grainDirection's titleOfSelectedItem() as string)))
			jobNode's addChild_(grainDirectionNode)
            set runImpositionNode to (current application's NSXMLNode's elementWithName_stringValue_("runImposition", (runImposition's titleOfSelectedItem() as string)))
			jobNode's addChild_(runImpositionNode)
            set runPlanNode to (current application's NSXMLNode's elementWithName_stringValue_("runPlan", (runPlan's titleOfSelectedItem() as string)))
			jobNode's addChild_(runPlanNode)
            set frontSideNode to (current application's NSXMLNode's elementWithName_stringValue_("frontSide", (frontSide's titleOfSelectedItem() as string)))
			jobNode's addChild_(frontSideNode)
            set backSideNode to (current application's NSXMLNode's elementWithName_stringValue_("backSide", (backSide's titleOfSelectedItem() as string)))
			jobNode's addChild_(backSideNode)
            set RealNameNode to (current application's NSXMLNode's elementWithName_stringValue_("OrderID", (orderID's stringValue() as string)))
			jobNode's addChild_(RealNameNode)
			set SubOrderNode to (current application's NSXMLNode's elementWithName_stringValue_("SubOrderID", (subOrderID's stringValue() as string)))
			jobNode's addChild_(SubOrderNode)
			set JobNameNode to (current application's NSXMLNode's elementWithName_stringValue_("JobName", (JobName's stringValue() as string)))
			jobNode's addChild_(JobNameNode)
			set CustomerNameNode to (current application's NSXMLNode's elementWithName_stringValue_("CustomerName", (customerName's stringValue() as string)))
			jobNode's addChild_(CustomerNameNode)
			set jobNode to (current application's NSXMLNode's elementWithName_("JOBS"))
			jobNode's addChild_(jobNode)
			set finalOutputName to (orderID's stringValue() as string) & "_" & (JobName's stringValue() as string)
			set somePath to POSIX path of ((ServerName & finalOutputName) & ".xml" as string)
			set theXMLData to theDoc's XMLDataWithOptions_(current application's NSXMLNodePrettyPrint)
			theXMLData's writeToFile_atomically_(somePath, true)

Hi,

the error message says that somewhere you send the parent message to an NSString object instead of an NSXMLNode object.

the is probably the problem, the parameter of the addChild method is supposed to be a NSXMLNode object


set XMLOrderID to (orderID's stringValue() as string)
jobNode's addChild_(XMLOrderID)

Actually you can omit all as string coercions while creating NSXMLNode objects
and you forgot to add jobNode to the root node of theDoc