[Closed] XML parsing/reading using dotNet
Hi guys,
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.
Thanks!
There has to be several examples on this site already, have you searched here? I know that I have posted some.
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.
To load an Xml file, you can use the following code:
local XmlDoc = dotNetObject "System.Xml.XmlDocument"
XmlDoc.Load "PathToYourXmlDoc.Xml"
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.
Cheers,
Martijn
Hi suvakas,
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:
http://forums.cgsociety.org/showthread.php?p=5211640#post5211640
Cheers
Dave