CGTalk > Software > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 02-20-2013, 05:02 AM   #1
AdamMax
Frequenter
Adam Maxwell
Australia
 
Join Date: Apr 2005
Posts: 108
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
Code:
<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
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-20-2013, 06:16 AM   #2
Gravey
3D Dude
Joel Hewitt
Sydney, Australia
 
Join Date: Dec 2005
Posts: 880
i sense you have been working with a real programming language recently...

Code:
parentTag.AppendChild tagCreate( xmlDoc, "value_a", "value_b", "value_c")
in maxscript would be
Code:
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-20-2013, 11:53 PM   #3
AdamMax
Frequenter
Adam Maxwell
Australia
 
Join Date: Apr 2005
Posts: 108
Thanks Gravey,
Bouncing between languages makes for silly mistakes.
 
Old 02-20-2013, 11:53 PM   #4
CGTalk Moderation
Expert
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,478
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 11:45 AM.


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