Author Topic: XML and Visual Lisp  (Read 5111 times)

0 Members and 1 Guest are viewing this topic.

psuchewinner

  • Guest
XML and Visual Lisp
« 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. 


Columbia

  • Guest
Re: XML and Visual Lisp
« Reply #1 on: May 14, 2008, 10:10:20 AM »
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...

Code: [Select]
<?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>

psuchewinner

  • Guest
Re: XML and Visual Lisp
« Reply #2 on: May 14, 2008, 11:12:01 AM »
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



Columbia

  • Guest
Re: XML and Visual Lisp
« Reply #3 on: May 15, 2008, 07:47:35 AM »
I think there is still an error in the file.

This line of code should return an object, but instead it is returning nil
Code: [Select]
_$ (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.

psuchewinner

  • Guest
Re: XML and Visual Lisp
« Reply #4 on: May 15, 2008, 09:04:11 AM »
Nope.
Cant get it to work.   :|
Still get the "nil"
Still get the unknown name "GETELEMENTSBYTAGNAME" error.

Columbia

  • Guest
Re: XML and Visual Lisp
« Reply #5 on: May 15, 2008, 10:07:28 AM »
What are the exact contents of your XML file?

Columbia

  • Guest
Re: XML and Visual Lisp
« Reply #6 on: May 15, 2008, 10:09:35 AM »
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.

psuchewinner

  • Guest
Re: XML and Visual Lisp
« Reply #7 on: May 15, 2008, 10:56:33 AM »
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.

Columbia

  • Guest
Re: XML and Visual Lisp
« Reply #8 on: May 15, 2008, 11:22:11 AM »
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.

Glenn R

  • Guest
Re: XML and Visual Lisp
« Reply #9 on: May 15, 2008, 11:24:33 AM »
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.

Glenn R

  • Guest
Re: XML and Visual Lisp
« Reply #10 on: May 15, 2008, 11:26:36 AM »
Yeah, whitespace at that location is a no-no.