Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

GDL XML Extension

Anonymous
Not applicable
I am having trouble working with the GDL XML extension. I am trying to read a XML file created with Excel. I'm having trouble navigating through the file. I can open it fine, and can get to the root node fine, but cannot do anything after that.

Here is the code for the XML file
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<Row>
		<teamMember>Team Member 1</teamMember>
		<role>Role 1</role>
		<street>123 Fake Street</street>
		<city>Houston</city>
		<state>Texas</state>
		<zip>77077</zip>
		<phoneNumber>123 456 7890</phoneNumber>
	</Row>
	<Row>
		<teamMember>Team Member 2</teamMember>
		<role>Role 2</role>
		<street>456 Real Street</street>
		<city>Houston</city>
		<state>Texas</state>
		<zip>77077</zip>
		<phoneNumber>123 098 7654</phoneNumber>
	</Row>
</Root>
The GDL script is attached. Everything is in the Parameter script, and is using the PARAMETERS command to update the values in the parameter list. This is my first attempt at working with the XLM extension and I am not quite sure if my problem is with the GDL or with the XML. Any help is greatly appreciated
8 REPLIES 8
Anonymous
Not applicable
I am starting to get a handle on the XML extension, but still have a few issues. If anyone is using it, please chime in.

The structure of my XML file is the base element is ROOT. There are 2 ROW elements that are children of ROOT. Simplified version below.
<ROOT>
  <ROW>
    Row Content
  </ROW>
  <ROW>
    Row Content
  </ROW>
</ROOT>
When I get the number of children on ROOT, instead of getting the expected 2 it returns 5. As I start stepping into ROW, I get first a NODE type of Text with a value of a square (yup, a square shows up as the value... this is a string type variable) and name of #text and the next NODE is type Element with a blank value and a name of Row.

I am unsure where this tet node is coming from as well as the odd number of children of ROOT. This also happens with the children of ROW. There is exactly 2*(expected children)+1. Now if this consistenly holds up as the way the XML Extension reports back the XML file I can code around it, but I am really curious as to where this mystery information is coming from.
ztaskai
Graphisoft Alumni
Graphisoft Alumni
Hi Michael,

This behavior doesn't come from GDL or the GDL XML extension. This is the normal way XML files are parsed. All textual information between reqular nodes are stored in so called text nodes. The content of your first text node is a new line and a tab - one of these characters you see as a square. In normal XML processing you should skip the text nodes.

Regards,
Zsolt
Zsolt Táskai
ArchiCAD Development - GDL Team
AC13, AC14 and upwards...
Anonymous
Not applicable
Zsolt,

Thanks for your explanation. It is very helpful.
Anonymous
Not applicable
One more problem I am experiencing is with error checking on opening the xml file. I am trying to OPEN a non-existant XML file. Starting from the example in the GDL manual my open code is
channel =OPEN ("XML", "wrongfilename.xml", "rl")
Next I use an IF statment
IF channel > 0 THEN ... ELSE ... ENDIF
The code in the ELSE section never executes. I thought that channel should only be greater than 0 if the xml file opens successfuly. Any ideas on what I am doing wrong?
ztaskai
Graphisoft Alumni
Graphisoft Alumni
Michael wrote:
One more problem I am experiencing is with error checking on opening the xml file. I am trying to OPEN a non-existant XML file. Starting from the example in the GDL manual my open code is
channel =OPEN ("XML", "wrongfilename.xml", "rl")
Next I use an IF statment
IF channel > 0 THEN ... ELSE ... ENDIF
The code in the ELSE section never executes. I thought that channel should only be greater than 0 if the xml file opens successfully. Any ideas on what I am doing wrong?
I'm afraid you're right. Theoretically, it can be -1 if some error occurs during opening the file. In practice, such an error produces an interpretation error and the whole interpretation is stopped. I guess you preferred it ran on with the -1 channel. Is this the case?

Regards,
Zsolt
Zsolt Táskai
ArchiCAD Development - GDL Team
AC13, AC14 and upwards...
Anonymous
Not applicable
I would prefer it to return a -1. I have scrited a visual 2D warning that displays if there is a problem with the XML file, but unfortunately can't get it to ever display the error.
ztaskai
Graphisoft Alumni
Graphisoft Alumni
OK, crystal clear. I'll talk about it with some colleagues and we'll enter it in our issue tracking system. I won't promise a schedule but hopefully it will get into the next main version in 2010.

Thanks again for the idea.

Regards,
Zsolt
Zsolt Táskai
ArchiCAD Development - GDL Team
AC13, AC14 and upwards...
Anonymous
Not applicable
Zsolt,

I have found another quirk with the XML Extension. It seems that ArchiCAD is somehow cacheing the xml file. It is enterend into the gdl part by name, and is in the loaded library. However, if I make a change to the xml file and reload the library, ArchiCAD doesn't register a change in the file... it still uses the orginal value, not the updated one. I have to change the way the name is entered (ie if the file is orgianlly typed as "Form1.xml" I have to re-type it in as "form1.xml"). Smae name, same file, just different case on the file name. Is there a workaround to this?

The only other solution I have found is to quit ArchiCAD completely and then re-open the ArchiCAD file. It would be better if reloading the library took care of this.

Thanks for all your help so far.