How does revAppendXML work?
John Patten
johnpatten at mac.com
Fri May 26 15:44:11 EDT 2006
Thank for the tip Sarah!
I tried your suggestion and the strange thing is I get an error after:
revAppendXML targetXMLFile, "StudentURL_table", tXMLdata
However, when I ask it to dump out the xml file it appears to have appended the xml files but, I think, in the wrong format.
Here's what it creates:
-------------------------snip-------------------------
<?xml version="1.0"?>
<StudentURL_table>
<URL IDnum="1">
<subject> Art</subject>
<key_words> Fine Art</key_words>
<Grade> 5</Grade>
<Standard> Creativity</Standard>
<Title> SPARK Site</Title>
<Description> This site is great for introducing students to the varied definitions of fine art and expression.</Description>
<Submitted_by> John Art</Submitted_by>
<emailAddress> art at mail.com</emailAddress>
<school> Orchard School</school>
<WebAddress> www.kqed.org/spark</WebAddress>
</URL>
<URL IDnum="2">
<subject> Art</subject>
<key_words> San Fracicso, Museum of Modern Art</key_words>
<Grade> 5</Grade>
<Standard> VAPA</Standard>
<Title> SFMOMA</Title>
<Description> The San Francisco Museum of Modern Art</Description>
<Submitted_by> John Art</Submitted_by>
<emailAddress> art at mail.com</emailAddress>
<school> Orchard School</school>
<WebAddress> www.sfmoma.org</WebAddress>
</URL>
<StudentURL_table>
<URL IDnum="1">
<subject> Art</subject>
<key_words> Fine Art</key_words>
<Grade> 5</Grade>
<Standard> Creativity</Standard>
<Title> SPARK Site</Title>
<Description> This site is great for introducing students to the varied definitions of fine art and expression.</Description>
<Submitted_by> John Art</Submitted_by>
<emailAddress> art at mail.com</emailAddress>
<school> Orchard School</school>
<WebAddress> www.kqed.org/spark</WebAddress>
</URL>
<URL IDnum="2">
<subject> Art</subject>
------------------------------------snip------------------
And it ends file with:
-----------------------------------snip---------------------
<WebAddress>www.sfmoma.org</WebAddress>
</URL>
<URL IDnum="3">
<subject> Art</subject>
<key_words> Fine Art</key_words>
<Grade> 5</Grade>
<Standard> Creativity</Standard>
<Title> SPARK Site</Title>
<Description> This site is great for introducing students to the varied definitions of fine art and expression.</Description>
<Submitted_by> John Art</Submitted_by>
<emailAddress> art at mail.com</emailAddress>
<school> Orchard School</school>
<WebAddress>www.kqed.org/spark</WebAddress>
</URL>
</StudentURL_table>
</StudentURL_table>
------------------------------------snip-----------------------
I was hoping that revAppendXML would renumber the attributes, I think that's what they are called, i.e. "<URL IDnum=3"> I guess that is not the case. But what is strange is I get the "xmlerr" message after the first revAppendXML command, but at the end it shows all the appends to the original XML file...???
Thanks!
John Patten
SUSD
>
>
> ...
>
> I want to take these multiple XML files and combine them into one large xml file with the same format.
>
> I was thinking I could do something like this:
>
> answer folder "Select XML folder" as sheet
> if it = "" then exit mouseUp
> set the defaultFolder to it
>
>
> put the files into tFiles
> put the number of lines of tFiles into tNumberofXMLFiles
> put line 1 of tFiles into theFileName
> put URL ("file:" & theFileName) into tData
>
> get revCreateXMLTree(tData,true,true,true)
>
> put the result into targetXMLFile
>
>
> put 1 into x
> repeat tNumberOfXMLFiles
>
>
> revAppendXML targetXMLFile,"/StudentURL_table/",URL "file:" & line x of tFiles
> add 1 to x
> end repeat
> --
> Put revXMLText(targetXMLFile,,true)
>
> end mouseUp
>
> -----------------------------------------------
>
> However, I appear to be misunderstanding what revAppendXML does, or how to use it correctly.
>I can't see any major problem with what you are doing, except possibly
>for the specification of the parentNode for the revAppendXML command.
>Try leaving out the /'s.
>I would also recommend doing it in 2 stages: read the file into a
>variable, then append the variable. e.g.
> put URL ("file:" & line x of tFiles) into tXMLdata
>revAppendXML targetXMLFile, "StudentURL_table", tXMLdata
>I always surround the file stuff with brackets before using put or get
>URL. It seems to be more reliable.
>And after each XML command or function, check the result and see if it
>contains "xmlerr".
>HTH,
>Sarah
More information about the use-livecode
mailing list