Exploring the XML File Format

by Nate Hekman on October 6, 2009

XML File Format Series
1. Exploring the XML File Format
2. Exploring the XML File Format – Part 2
3. Exploring the XML File Format – Part 3 – SLOPE/W

Let’s take a deeper look into the .gsz file format.  You’ll remember I’ve mentioned a few times that a .gsz file is just a zip file that contains a bunch of other files.  One of those inner files is what we call the definition file.  The definition file has a .xml extension and generally has the same name as the .gsz.

(If you’ve solved your analyses you’ll see several .xml files.  The definition file is the one in the root directory.)

I’m assuming you are already somewhat familiar with xml in general.  If that’s not a fair assumption, you may want to do some additional reading:

XML Tutorial for the very beginner.
XML definition on wikipedia.

The XML

I’m going to look at the definition file for SLOPE Tutorial.gsz, since it’s included with every installation of GeoStudio. You can also download it here.

There’s a lot of detail in the definition file. Today I’ll just look at the bigger blocks. I may delve into more specific areas in later posts, depending on what feedback I get from you.

Use Notepad or Internet Explorer to open SLOPE Tutorial.xml if you want to follow along.  The first line is:

<?xml version=”1.0″ encoding=”utf-8″ standalone=”yes”?>

That’s the first line of any xml file, and simply defines it as being xml.

<GSIData Version=”7.15″>

The next line is the opening tag that defines this as a GeoStudio file, the “GSIData” block.  (“GSI” stands for “GEO-SLOPE International”.)  This line also identifies the version of GeoStudio that saved the file.

Now comes the good stuff.  A while back I described how a GeoStudio file has “global” objects such as regions and materials which are available to every analysis, and how when you assign a material to a region you’ve just formed a link or “association” between those two objects.  Well this next level in the xml file describes all those “global” objects.

<Analyses Len=”2″>…</Analyses>

The Analyses block describes each analysis.  (From KeyIn – Analyses.)

The Len=”2″ part just indicates how many analyses there are.  It’s not strictly necessary in normal xml, but it helps GeoStudio load the file more quickly because it knows in advance how many analyses are in that block.

<BCs Len=”8″>…</BCs>

The BCs block describes each boundary condition.  (From KeyIn – Boundary Conditions.)  Note that not every boundary condition in the list is necessarily used by your analyses–in fact there are a handful of default boundary conditions created in every file because they’re so common.\

<Contexts Len=”2″>…</Contexts>

This is where the associations are recorded.  There’s a context for each analysis to record which regions and materials are connected, which lines and boundary conditions, and so on.

<Contour>…</Contour>

The Contour block describes how results are visualized.

<Coordinates>…</Coordinates>

Defines the engineering coordinates, page extents and so on.  (From Set – Units & Scale and Set – Page.)

<FileInfo … />

Contains information about the file.  (From KeyIn – Analyses, then click on the root item in the tree.)

<Functions>…</Functions>

The Functions block holds all the functions you’ve defined.  (From the various KeyIn – Functions.)  They’re split into several categories such as <Boundary>, which in turn contains categories such as <StressStrain>.

<GeometryItems>…</GeometryItems>

This is your geometry definition.  It contains coordinates for all the points, lines and regions.

<Materials Len=”2″>…</Materials>

All materials you’ve defined.  (KeyIn – Materials.)

<MeshItems>…</MeshItems>

The mesh that was generated from your regions.  Note that when you open a file, the mesh may be regenerated, so don’t edit this section, your changes may not be used.  If you want to adjust your mesh, you must do it in the GeometryItems section by applying mesh constraints to regions, lines or points.

<SketchItems>…</SketchItems>

Contains sketch lines, circles, text, images and so on.  All the “markup” that doesn’t actually affect results.  (From the Sketch menu.)

<SlopeItems Len=”2″>…</SlopeItems>

Each product (SLOPE/W, SEEP/W, etc.) can have its own section with data that’s specific to that product.  For example, SLOPE/W uses this section to describe slip surfaces, piezometric lines, and so on.  Like the <Contexts> section, there is one <SlopeItem> section per SLOPE/W analysis.

<View>…</View>

Your view preferences, most recent zoom and scroll position, and so on.

</GSIData>

And finally we’re done with the outer GSIData block.

That’s the GeoStudio xml format at a very high level.  I’ll dig deeper into specific sections over the next few weeks.  Let me know if there is anything in particular you’d like covered.

Giang, if you’ve discovered some gems of wisdom as you’ve been working through this yourself, feel free to share!

{ 7 comments… read them below or add one }

1

Bruno 03.10.13 at 12:48 pm

Hi Nate,
So you describe .gsz files as zip files with xml files. When I unzip a functioning .gsz file and then zip it back and change the extension to .gsz, I get an error that says it failed to read project data from the xml file. What’s going on?
I’d like to be able to manipulate the program xml files without having to open geo-slope.

All the best,
Bruno

2

Nate 03.11.13 at 8:45 am

I would certainly expect that to work, Bruno. If the xml file that you zip up is the same one you extracted, GeoStudio should be able to read it just fine. Care to send me the file? hekman [at] geo-slope [dot] com

3

Muqdad 08.10.16 at 2:24 am

yes that same thing happen with Bruno.
I just change some parameter in SEEPW file then decompress the file. but SEEPW doesn’t read the file ???

THANKS

4

Nate Hekman 08.10.16 at 7:31 am

Muqdad, it’s hard to know exactly what’s going wrong without some more detail and experimentation.

1. Start by working just with the xml. Extract the xml file into its own folder, and have SEEP/W open the .xml file directly. It should succeed.
2. Now make a very small change in the xml, like just changing the value of a material property. Have SEEP/W open the xml again, and confirm the change “took”.

Now that we know the xml is valid, we can take the next steps to work with a .gsz:
3. Start simple: just extract the xml, then zip it again into a new zip file (without making any changes to the xml) and change the extension to .gsz, and see if SEEP/W will open it. It should work. If it doesn’t, that would indicate there’s something wrong with the zipping.
4. Now take the xml that you modified (that we already confirmed can open in SEEP/W), and zip it up and give it a .gsz extension, then see if SEEP/W will open it.

Hopefully these troubleshooting steps will help you figure out where the problem is.

Note that Notepad.exe, the built-in text editor that comes with Windows, is not a great text editor, and it could possibly be messing up the xml file. If you find that after editing the xml you can’t open it in SEEP/W, I would recommend a (free) tool like Notepad++ instead.

5

Alessia 12.01.16 at 4:34 am

Hi Nate,
thanks a lot for this blog, it is extremely useful!
Like other users, I am trying to manipulate the xml file because I need to run hundreds of simulations that differ just for the value of one or two parameters. I think I have a problem when I compress the xml file back into a .gsz but I can’t figure out what it is. I am following the steps you recommended to Muqdad in your previous reply. If I save a .gsz file into .xml, change my parameter and then open the .xml in Geostudio it works fine and I can see that the change has taken place (step 1 and 2). However, if I compress the .xml into .gsz and I try to open it in Geostudio I see the following error message: “Failed to open myfile.gsz. The central directory was not found in the archive (or you were trying to open not the last disk of a multi-disk archive)”. I don’t really understand what this means. I am using WInRar to compress the file. Could you please help me? Thanks a lot

6

Nate Hekman 12.01.16 at 8:03 am

Hello Alessia. It certainly sounds like the .gsz is not in the format GeoStudio expects, and in particular that it isn’t in a standard .zip format. WinRAR can create .zip or .rar files. I wonder if you’re actually creating a .rar?

I haven’t used WinRAR myself (I normally use the free 7zip, and I’ve also used WinZip), but if it can create a standard .zip file, I would certainly expect it to work.

7

Alessia 12.02.16 at 9:10 am

Hi Nate, thanks for your reply. I have created a .zip file in WinRar and it resulted in the error message I reported, but if I use 7zip on the same file it works… So there must be something wrong when compressing the file with WinRar. Using 7zip has solved my problem, so thank you very much! This blog is extremely useful and I’m sure I will be coming back here very often 🙂

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>