xml editing woes... help please.

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 02 February 2013   #1
xml editing woes... help please.

Hi guys,
I have to create an xml document with a whole heap of repeating elements and a few unique elements

something like this

<root>
   <parentTag>
        <tag01 same01="1" same02="2 same03="3" variable01="a" variable02="b" />
        <tag01 same01="1" same02="2 same03="3" variable01="a" variable02="b" />
        <tag01 same01="1" same02="2 same03="3" variable01="a" variable02="b" />
        <tag01 same01="1" same02="2 same03="3" variable01="a" variable02="b" />
        ..... on and on and on.


Rather than have huge repetitive lines of code I tried to bundle it into a function.
Here's my code

dotnet.loadAssembly "system.xml.dll"
xmlDoc=dotNetObject "system.xml.xmlDocument"

function tagCreate document a b c =
(
    tag = document.CreateElement "tag01"
    tag.setAttribute "same01" "1"
    tag.setAttribute "same02" "2"
    -- on and on, see above
    tag.setAttribute "variable01" a
    tag.setAttribute "variable02" b
    tag.setAttribute "variable03" c
    return tag
)

-- 
xmlDoc.load xmlFilePath

rootTag = xmlDoc.CreateElement "root"
xmlDoc.AppendChild rootTag

parentTag = xmlDoc.CreateElement "parentTag"
rootTag.AppendChild parentTag

parentTag.AppendChild tagCreate( xmlDoc, "value_a", "value_b", "value_c")
parentTag.AppendChild tagCreate( xmlDoc, "value_a", "value_b", "value_c")
parentTag.AppendChild tagCreate( xmlDoc, "value_a", "value_b", "value_c")
parentTag.AppendChild tagCreate( xmlDoc, "value_a", "value_b", "value_c")
--- on and on where a b and c are different but all the other same tags will be the same


This isn't working

-- Error occurred in anonymous codeblock; filename: filename; position: 20782; line: 510
-- Syntax error: at ,, expected <factor>
-- In line: parentTag.AppendChild TagCreate( xmlDoc,


Sorry, I rewrote this to make it simpler so there may be some editing problems.
 
Old 02 February 2013   #2
i sense you have been working with a real programming language recently...

parentTag.AppendChild tagCreate( xmlDoc, "value_a", "value_b", "value_c")
in maxscript would be
parentTag.AppendChild (tagCreate xmlDoc "value_a" "value_b" "value_c")
ie. wrap the function and arguments in brackets and remove the commas between the arguments
 
Old 02 February 2013   #3
Thanks Gravey,
Bouncing between languages makes for silly mistakes.
 
Old 02 February 2013   #4
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 03:14 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.