View Full Version : XML parsing/reading using dotNet
06-20-2008, 10:20 AM
I've been trying to find some basic info about loading an xml file via maxscript and System.Xml.dll, but failed.
Most of the scripts I have found are either too complex or only about writing an xml file.
So i thought i ask, if anybody has a very basic/simple example of how to read elements from xml file using dotNet ? Or maybe someone can point me to a link that describes the basic usage of System.Xml.dll
Any help would be good.
There has to be several examples on this site already, have you searched here? I know that I have posted some.
06-20-2008, 12:41 PM
Yes, I searched the forum and found some examples, but most of them are about writing to xml (your example is about writing too =), but not about reading. So a simple example how to get like a <blah> tag from a random xml would be good. Ok. There are more complex examples around, but I thought i save some time and ask a simple example. Right now i'm looking at someones 100 lines long script and trying to figure out the reading part without knowing the syntax of the dotnet xml parser or anything.
06-22-2008, 12:13 AM
To load an Xml file, you can use the following code:
local XmlDoc = dotNetObject "System.Xml.XmlDocument"
Lots of info on reading/parsing the file can be found on the web, for example:
http://www.c-sharpcorner.com/UploadFile/bulentozkir/ReadingXmlUsingXmlDocument11142005010141AM/ReadingXmlUsingXmlDocument.aspx (using GetElementsByTagName)
http://www.java2s.com/Code/VB/XML/ReadinganXMLdocument.htm (using XmlNodeReader)
http://vbnetsample.blogspot.com/2007/07/read-xml-content-by-xmldocument.html (using SelectNodes)
Just Google it and you'll find loads of information.
06-22-2008, 02:44 AM
I you want to load (or save) XML I wrote a couple of small stucts for doing so. I posted them in the Python thread (as there is python version as well). It works well for loading/reading and writing it is also quite simple so it would be fine to use a basic example the maxscript version makes use of the dotnet xml stuff. You can download it here:
06-22-2008, 08:14 PM
Thank you guys !
I'll check those out.
06-22-2008, 08:14 PM
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.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.