XML Basics - Part 1

Post Reply
GaryG
Posts: 880
Joined: 19 Jul 2009, 10:32

XML Basics - Part 1

Post by GaryG » 05 Sep 2011, 18:56

So guys, back to where we left !

Let's start with this simple gauge:

Code: Select all


<Gauge Name="ALT DISPLAY" Version="1.0">
   <Image Name="NAV.bmp" ImageSizes="97,29"/>
   <Element>
      <Element>
         <Position X="5" Y="2"/>
         <Text X="87" Y="25" Bright="Yes" Length="6" Font="Quartz" Color="VIOLET" Adjust="Center" VerticalAdjust="Center" Multiline="No" Fixed="Yes">
            <String>%((A:Autopilot altitude lock var, feet))%!05.0f!</String>
         </Text>
      </Element>
   </Element>
   <copyright>(c)2003 Ken Mitchell [justmitch@charter.net]</copyright>
</Gauge>

<Gauge Name = > </Gauge> - Explains itself. It needs to be there to begin an XML gauge. Everything lies between those lines.

<Image Name = /> - This one displays the gauge background. Only .bmp files are accepted.

<Element> </Element> - Introduces a new element. There are two here, one is a sub-element of the other. I would call them elemenception. This is useful in certain cases. Will explain later on. Please notice how it starts with a <Element> and closes with a </Element>

<Position /> - required to instruct where the element will lie. If there is already one in the previous element declaration, the datum is taken as that point. For example: if a <Position> in the first element is:
<Position X="5" Y="2"/>, then the first element will move to that point. If a sub-element is declared, like the example above and the position is set to be: <Position X="8" Y="5"/>, then the position of the sub-element is actually <Position X="13" Y="7"/> from the origin.

<Text/> : There is a tutorial explaining those terms at fs2x.com Link here: http://www.fs2x.com/Tutorials_files/XML ... 20V2_0.pdf

<String></String> - This is important. If you just type something between those lines, it will appear "as is" in fs. However, in the case above, what's happening is that an A:Var is being displayed, in this case being Autopilot Altitude lock. The % sign means that it needs to be evaluated. The !05.0f! means that it should display a maximum of 5 integers. Similar to this would be !3d!. Also, if !05.1f! was written, the number displayed would be of the form of XXXXX.X. Please note that A:Vars are not invented. These are taken either from here: http://www.fs2x.com/Tutorials_files/FS2 ... iables.txt or else: http://msdn.microsoft.com/en-us/library/cc526981.aspx.

The former are 100% compatible with FS9 whilst the latter are 100% compatible with FSX even though most of those listed in the latter are FS9 compatible.

Don't hesitate to post any queries you have below. This was a mini tutorial. I advise that you start by editing an XML gauge that you already have so that you avoid problems when putting them into FS.

NOTE: If syntax errors are present, e.g. a missin ">" or words spelt wrongly, the XML gauge will completely disappear from FS. If a gauge is small, like the one above, it might be easy to tackle the problem, but in cases were lines of code are 500+, it might be your worst nightmare. So proceed slowly and always confirm your last step to avoid further problems.

Enjoy, regards

User avatar
Srilanka
Posts: 186
Joined: 23 Jan 2011, 07:18

Re: XML Basics - Part 1

Post by Srilanka » 07 Sep 2011, 11:08

<copyright>(c)2003 Ken Mitchell [justmitch@charter.net]</copyright>Can i leave the following blank?? or like <copyright></copyright>??

GaryG
Posts: 880
Joined: 19 Jul 2009, 10:32

Re: XML Basics - Part 1

Post by GaryG » 07 Sep 2011, 11:15

you can leave that, I kept it there just so that everybody knows that the sample gauge is taken from Ken's work.

User avatar
Srilanka
Posts: 186
Joined: 23 Jan 2011, 07:18

Re: XML Basics - Part 1

Post by Srilanka » 07 Sep 2011, 11:21

@GaryG,For FSX should it be a 32 bit bmp file?

GaryG
Posts: 880
Joined: 19 Jul 2009, 10:32

Re: XML Basics - Part 1

Post by GaryG » 07 Sep 2011, 11:25

yes, it needs to be just like the other bmps

User avatar
iheart707
Posts: 189
Joined: 07 Mar 2010, 22:39

Re: XML Basics - Part 1

Post by iheart707 » 13 Sep 2011, 05:24

Perhaps programs like Notepad++ might be worth mentioning in this post as well. I do like the tree method and the colors and the structure vs regular notepad. After all, it can be hard for visual people to simply work in black and white all the time.

GaryG
Posts: 880
Joined: 19 Jul 2009, 10:32

Re: XML Basics - Part 1

Post by GaryG » 13 Sep 2011, 15:03

I use Visual C++ 2010 for that but yes, it is of great help

hmjr
Posts: 4
Joined: 12 Apr 2013, 18:48

Re: XML Basics - Part 1

Post by hmjr » 11 Aug 2013, 08:19

I found at least 2 errors in the fs2x tuturals.

1/ &gt and &lt has to be ">" and "<" (input, greater and smaller signs)

2/ Setting engine power: 16384 for 100% power setting is OK (f.i. 16384 (> K:AXIS_THROTTLE2_SET) )
80192 for 50% power is not OK
0% for zero power gives 50% power setting, 0% power needs neg 16384 (16384/-/ (> K:AXIS_THROTTLE2_SET) )
100 %negative power (reverse thrust) needs -55000 in my case

hmjr
Posts: 4
Joined: 12 Apr 2013, 18:48

Re: XML Basics - Part 1

Post by hmjr » 18 Aug 2013, 06:06

I have to make a small correction on my remark referring the "<" and ">" and "&gt" and "&lt" signs in the XML course manual from fs2x.
Up till now I used Microsoft XML Notepad 2007 and this editor caused this problem.
If you use Microsoft Visual C++ 2010 f.i. this problem does not occur .
Even the signs ">" and "<" in the edited XML files are printed on your screen as "&gt "and "&lt" when you use this editor.
hmjr

hmjr
Posts: 4
Joined: 12 Apr 2013, 18:48

Re: XML Basics - Part 1

Post by hmjr » 01 Dec 2013, 11:46

I am looking for someone who also wants to become a basic xml programmer.
I studied already a few cm's of tutorials and examples of xml programs and still have a lot of problems with this stuff.
Is there anybody who is in a simular situation and wants to have a fellow to have discussions about this item and to help eachother with programming problems.
I modified already a several of A380 xml files and have build a working 2D panel for A380.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests