Hey there.
I'm (again!) using xmllib to write a list of data into an XML file. I am doing this over and over in a repeat loop, essentially adding child after child and it workd for the most part. However, using a generic dataset from my list adding the child trips up on a particular entry. Comparing data I can't see any real difference that would cause a problem, but perhaps someone can offer some insight into the error message so that I can see what I'm missing.
The relative script code looks something like this:
repeat with j from 1 to count of items in assetList
...
set theXML to (XMLOpen masterXML) set theXMLRoot to XMLRoot theXML set assetCount to XMLCount theXMLRoot set theAsset to (XMLXPath theXMLRoot with "asset[@id=\"" & assetIDNumber & "\"]") if theAsset = {} then -- The Asset does not exist set theData to "<asset id=\"" & assetIDNumber & "\"> </asset>" set newAsset to XMLNewSibling theData after (XMLChild theXMLRoot index assetCount) repeat with k from 1 to count of items in mdFields set XMLElementText to "<value id=\"" & item k of mdFields & "\">" & item k of assetFieldValues & "</value>" display dialog XMLElementText XMLNewChild XMLElementText at newAsset keep blanks yes end repeat XMLSave theXML else -- display dialog "The Asset exists" end if end repeat
mdFields contains a list of the field names I need to add (XML value ID) and assetFieldValues is the list of the contents of each field. Both are lists of text strings and I have already verified that both lists have the same number of elements and correlate.
I repeat this loop over and over for each asset for which I have built the two relative lists, writing to the existing XML after the last element each time. It works fine for awhile and then I get this error:
AppleScript Error line 1 xmlParseEntityRef: no name
Referencing the XMLNewChild line of code.
The XML I am writing to looks something like this:
<?xml version="1.0"?> <session> <asset id="111845"> <value id="ASSET_NUMBER">111845</value> <value id="PA_MD_CUST_FILENAME">NSHTWH_Cohen.mov</value> <value id="CUST_TITLE">NSHTWH_Cohen</value> <value id="PA_MD_CUST_KEYWORD_WEB_UI_NAME">Matthew Cohen</value> <value id="PA_MD_CUST_KEYWORD_WEB_TOPIC">Womens Health</value> <value id="PA_MD_CUST_KEYWORD_WEB_TOPIC_LIST">EMPTY</value> <value id="PA_MD_CUST_KEYWORD_WEB_TAG">Needs tag</value> <value id="PA_MD_CUST_KEYWORD_WEB_LOGLINE">EMPTY</value> <value id="PA_MD_CUST_KEYWORD_SEARCH_ADDITIONAL">matthew, cohen, 3, healthy, tips, life, happy</value> </asset> <asset id="111847"> <value id="ASSET_NUMBER">111847</value> <value id="PA_MD_CUST_FILENAME">NSHQZQ_Polypharmacy.mov</value> <value id="CUST_TITLE">NSHQZQ_Polypharmacy</value> <value id="PA_MD_CUST_KEYWORD_WEB_UI_NAME">Too Many Medications</value> <value id="PA_MD_CUST_KEYWORD_WEB_TOPIC">Internal Medicine</value> <value id="PA_MD_CUST_KEYWORD_WEB_TOPIC_LIST">EMPTY</value> <value id="PA_MD_CUST_KEYWORD_WEB_TAG">EMPTY</value> <value id="PA_MD_CUST_KEYWORD_WEB_LOGLINE">EMPTY</value> <value id="PA_MD_CUST_KEYWORD_SEARCH_ADDITIONAL">medications, too many, polypharmacy, megapharmacy, dangerous</value> </asset> </session>
I realize that this may be an incomplete description of my issue, but hopefully someone may have some insight as I hack my way through using xmllib to write my XML file. Thanks for your help and patience.
Steve |