TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: psuchewinner on May 13, 2008, 04:38:59 PM
-
I recently found this post started by columbia about XML and Visual Lisp
http://www.theswamp.org/index.php?topic=525.msg6773#msg6773
I downloaded the API and the sample XML document, tried it and this is what I get:
(vl-load-com) ;; to make sure everything is peachy with Active-X
(load "xml-api.vlx") ;; load up the API
(setq oSettings (xml-Get-XMLObject "c:\\dwgset.xml"))
#<VLA-OBJECT IXMLDOMProcessingInstruction 02402a40>
(setq oLayers (xml-Get-Child oSettings nil "Layers"))
nil
(setq oRegen (xml-Get-Child oSettings "DrawingVars" "RegenAuto"))
; error: ActiveX Server returned the error: unknown name: GETELEMENTSBYTAGNAME
Anybody know what it means? Can anybody help? I am trying to learn the whole XML file thing but am getting frustrated.
-
If you used the sample XML document word for word, then it won't work. There are errors in that document.
Way back when, I must not have checked it before I posted it.
Listed below is a revised document listing. Let me know if that works for you. If not, maybe we can hack through it...
<?xml version="1.0"?>
<Settings>
<Layers>
<Layer Name="Walls" Color="2" LineType="continuous"/>
<Layer Name="Furniture" Color="3" LineType="HIDDEN"/>
</Layers>
<DrawingVars>
<RegenAuto>1</RegenAuto>
<EdgeMode>0</EdgeMode>
<Osmode>383</Osmode>
</DrawingVars>
</Settings>
-
Still not working.
Here is my code and below that, are my errors.
;;;;;Code ----------
(defun c:xml_test ()
(vl-load-com)
(setq MyXmlfile (findfile "dwgset.xml"))
(setq XmlApi (findfile "XML-API.vlx"))
(load XmlApi)
(setq oSettings (XML-Get-XMLObject MyXmlFile))
(setq oLayers (xml-Get-Child oSettings nil "Layers")) ;; gets the Layers collection
(setq oRegen (xml-Get-Child oSettings "DrawingVars" "RegenAuto"))
(xml-Get-Child-Value oSettings "DrawingVars" "RegenAuto") ;; returns "1"
);end xml_test
errors:
_$ (setq oSettings (XML-Get-XMLObject MyXmlFile))
#<VLA-OBJECT IXMLDOMProcessingInstruction 02405758>
_$ (setq oLayers (xml-Get-Child oSettings nil "Layers"))
nil
_$ (setq oRegen (xml-Get-Child oSettings "DrawingVars" "RegenAuto"))
; error: ActiveX Server returned the error: unknown name: GETELEMENTSBYTAGNAME
_$ (xml-Get-Child-Value oSettings "DrawingVars" "RegenAuto")
; error: ActiveX Server returned the error: unknown name: GETELEMENTSBYTAGNAME
-
I think there is still an error in the file.
This line of code should return an object, but instead it is returning nil
_$ (setq oLayers (xml-Get-Child oSettings nil "Layers"))
Navigate to your XML file in Windows Explorer and use Internet Explorer to open that file. It will tell you if the document is not correct, and it will even tell you where in the document it failed to parse.
Let me know how that works.
-
Nope.
Cant get it to work. :|
Still get the "nil"
Still get the unknown name "GETELEMENTSBYTAGNAME" error.
-
What are the exact contents of your XML file?
-
You're getting the error about the GETELEMENTSBYTAGNAME because XMLDom is an error state. That usually is the result of an error in the XML file.
Sorry about the double post, my clicking finger is faster than my brain.
-
That clears it up some but it is still a little confusing. My XML file Pretty much the same as your example. I did however, run it through a validator on the my3school (not sure if that is exactly it or not) website and it found that the quotation marks were messed up. I fixed them and it got no errors. I do not understand how to see if there are any errors when opening it in IE. I open it in IE and it looks ok. Here is the XML. Should it be color coded?
<? xml version="1.0" ?>
<Settings>
<Layers>
<Layer Name="Walls" Color="2" LineType="continuous"/>
<Layer Name="Furniture" Color="3" LineType="HIDDEN"/>
</Layers>
<DrawingVars>
<RegenAuto>1</RegenAuto>
<EdgeMode>0</EdgeMode>
<Osmode>383</Osmode>
</DrawingVars>
</Settings>
Thanks for your help and for learning me. I apprecite it.
-
In the first line, try removing the whitespace surrounding the question marks, so this...
<? xml version="1.0" ?>
becomes this...
<?xml version="1.0"?>
Good Luck.
-
Later versions of IE will open an xml file when double clicked and parse the file for display as well as checking it for 'well formedness'.
Try leaving off one the closing tags in your xml and then try opening it in IE and it should spit it out with an error.
-
Yeah, whitespace at that location is a no-no.