View Full Version : Working with XML...
07-26-2005, 05:12 PM
... is the most frustrating thing I’ve done in a long time.
I give those of you who code gauges using this language a lot of credit for your patience and persistence. I've worked with Basic, HTML, PHP, and in C but XML is something else.
I’ve been trying to get a simple gauge to work for several days. Once I get a part functioning properly, I save the code in a backup text file using Notepad. I then continue working with the original code to add more content.
As I work on the original code, I usually modify it to the point where it no longer displays the gauge when I reload the aircraft. If I cannot find the problem, I replace the non-working code using the backup file which was the last known version that worked. However, that now no longer works although once it displayed the gauge fine.
I write the XML using Bonfire Studio (a freebie for XML from download.com) and it gives me several different views of the XML code including a tree view and a view using my browser. No matter which view I choose, the code looks identical to my backup version so I detect no added spaces or other not so obvious changes.
When I use Notepad for coding, the same problem will happen.
I CAB the xml and bmp's using a program called CabPack 1.4.
Any known problems with any of the software I’m using that may be causing my problem?
For the life of me I see no reason for code that once worked to suddenly take a holiday.
07-27-2005, 12:00 AM
Forget all those fancy, schamanzy "XML Editors" and use Wordpad.exe... In fact, if you install a "Reload Gauge" on your project panel, you can "unlock" the XML gauge files and do "real-time updating and testing" with your code as you work.
For your convenience, I've attached a working "Reload Gauges" gauge...
That way, you get immediate feedback in the sim of whatever changes or additions you have made, and can simply press Ctrl-Z in Wordpad to "undo" your latest mistake, er... changes! ;)
07-27-2005, 09:55 AM
Clever gauge! It saves a lot of re-load time. And you seem to be correct about using WordPad. Thus far it has cured my problem of the disappearing gauge.
Could you be more specific about "unlocking the XML gauge files and do real-time updating and testing".
I have read somewhere that the cab step can be eliminated by thus and such. Now that I need that info I can't find it again. Please elaborate and thanks for your help.
07-27-2005, 03:08 PM
Instead of creating the CAB file, create a folder (in the same place) with the same name as the CAB file and put all your gauge files inside that. It will work the same way.
Hope this helps,
07-27-2005, 05:52 PM
Tom,your method is not working for me.
This is the line from the panel.cfg file of the test aircraft.
gauge07=HLG!HLG, 51, 127, 110, 110
Inside the Gauges folder I made a new folder named HLG as your post suggested. Inside the HLG folder I placed the xml file and all associated bitmaps. I deleted the HLG.cab file which was inside the Gauges folder. Now the gauge no longer displays.
This obviously works for you so I must be misunderstanding your instructions.
I also tried placing the new HLG folder inside the panel folder of the test aircraft (instead of Gauges folder). But that too is a dud.
07-27-2005, 07:04 PM
Sorry, that's what I did and it worked fine (I put it in the plane's PANEL folder). Make sure the gauge is named HLG.xml.
07-27-2005, 08:46 PM
>Clever gauge! It saves a lot of re-load time. And you seem to
>be correct about using WordPad. Thus far it has cured my
>problem of the disappearing gauge.
>Could you be more specific about "unlocking the XML gauge
>files and do real-time updating and testing".
Place the "R" (Reload Gauge) in the upper left corner of your 2d panel window (0,0,20,20)
Load your XML code in your editor-of-choice, minimize (unless you have 2 monitors).
Start FS9, load your a/c, and then click the "R" button to unlock all the .xml files, so you can save changes.
Whenever you make changes in the XML gauge, Save, switch to FS9 and click the "R" button to see the changes immediately! ;)
07-28-2005, 08:49 AM
This morning I made a new folder inside the panel folder of my aircraft. All other files for the HLG gauge were deleted. I turned on FS and sure enough it loaded the gauge from my panel folder directly without having to cab them. So, it may have something to do with FS itself. Maybe it had to relearn where to look, I don’t know.
The panel load gauge works really great. Thanks for all your help. I'll get my gauge working sooner or later. Learning new code is always a bit difficult at first. Right now, I'm pulling my hair trying to get bitmaps to be correctly located on masks. I did discover that a Y axis coordinate of 7 caused the gauge to disappear. But a Y value of 007 caused the gauge to reappear. Sure wish all this was written somewhere in gory detail. SDK; Skimpy Details causes Kussin'.
07-28-2005, 07:19 PM
>Sure wish all this was written somewhere in gory
>detail. SDK; Skimpy Details causes Kussin'.
Actually, there are quite a few places to obtain "more help" with XML gauge coding.
http://freeflightdesign.com offeres "Tips," "Tutorials," and of course, specific forums just for panel & gauge developers.
There is also a terrific new resource at
There is a "Tutorials" section as well as a forum for XML gauge developers... ;)
07-29-2005, 08:49 AM
Yes, I had discovered the xml tutorials by Nick Pike at Fs2x. I found little at FreeFlightDesign that was of interest to me now. Nick’s tuts gave me a start in the right direction. But one man can know only so much and is limited by time to write free tutorials. They come down the pike, so to speak, rather slowly.
I do wish MS would give us comprehensive tuts because only they have the team who understands the intimate details. I’d be willing to pay for such SDK’s at least as much as I paid for FS9. For myself, modifying MSFS increases the fun and adds to the challenge of the sim itself. It would be even greater fun if one had a proper manual.
07-29-2005, 09:20 AM
One thing ive found usefull besides the fore mentioned tuts is the default xml gauges in FS9.By starting with a gauge that already works
for me its a bit easier to find out where I went wrong.One warning never ever look inside the gps.xml there is some serious black magic in there
It gave me such a headache :D
07-29-2005, 01:17 PM
It's funny you should mention the gps.xml. I was looking at those codes just yesterday. They did not give me a headache, but I did throw up...twice!
That is exactly the kind of coding a thorough SDK would cover. As it is, the SDK's are pretty much elementary school fare, just enough info to give you a measure of insight, then you are sent on your way. But, for ungifted scratch-your-head guys like me, I need some high school classes. If not for the additional info, at least the girls are more shapely.
07-31-2005, 08:26 PM
>Yes, I had discovered the xml tutorials by Nick Pike at Fs2x.
>I found little at FreeFlightDesign that was of interest to me
There is quite a bit of "meat" in the forum posts, but you do have to be modestly skilled at using the "Search" feature...
The other, more heavily XML oriented forum is the "Aircraft & Panel Design" forum at the "other major FS website," you know, "The One That Must Not Be Named" (here, at least).
If you aren't sure what I'm refering to, drop me a line at firstname.lastname@example.org and I'll 'splain it to you... ;)
08-01-2005, 08:41 AM
I don't know anything about unnamed boards. Haven't seen any such directives at this site so hope I don't inadvertently break any rules.
The best XML posts I've read so far were atavsim. However, most info is presently above my head since they directly answer a question by showing code but usually not in a "how to" or "this is why" manner. I am building up a doc of these post so maybe they will make more sense as my experience grows.
Since I have you on the phone would you please show me how to write math code to produce the angle below.
Angle = (A:VARIABLE 1) / (A:VARIABLE 2) * 60
A:VARIABLE 1 can be both positive and negative. I need both to move a needle left/right. But I don't need all the decimal places that the varables display. Is there a ABS function to drop those or a round-off function?
08-01-2005, 09:45 AM
If I may make a few observations .....
Firstly, when seeking assistance in forums, it always helps if you sign it with a real name and not just a nickname.
But that's just my opinion :-)
Secondly, yes (as Bill suggests) the Aircraft&Panel design forum onavsim is probably the best place to ask these kind of technical questions, since this forum appears to be the favorite of most gauge/panel designers (new and experianced) for this purpose.
About your actual question:
Angle = (A:VARIABLE 1) / (A:VARIABLE 2) * 60
In xml, using ReversePolishNotation, this would look like:
(G:Var1) (G:Var2) / 60 * int (>G:Var3)
with variable G:Var3 now holding the rounded value for ANGLE.
I donot know what your variables 1 and 2 are, so this is just an example on how you could write it in XML.
Furthermore (if you have a misunderstanding about "rounding"): unless you have a specific reason for "rounding" variables, you usually keep using their full resolution because you have all kinds of formatting features (like in "C") when a variable value needs to be displayed.
08-01-2005, 04:00 PM
I appreciate the code. I'll finish out this post with nickname so readers will know who is who. I don't know all the posting procedures yet so thanks for the advice. You mean there really is someone named Flying Turnip?
I've registered at avsim but can never get inside to post. I've gotten messages complaining about my cookies, but that was solved. After getting past that, now they say "no such password" when I try to sign in. I've asked for new password but they just ignore my request. So, until they find time to help, I'm limited to just reading and trying to decipher the postings. I've tried posting in the panel board here but that seems a dusty and lonely place.
In my previous post:
(A:VARIABLE 1) would be (A:VELOCITY BODY X, knots)
(A:VARIABLE 2) would be (A:AIRSPEED TRUE, knots)
Does this affect your example any?
08-01-2005, 06:43 PM
Using your real name instead of a nickname is NOT a posting procedure; anyone can do what he likes himself. I was just stating that I personally am more inclided to help someone when he puts his real name under a post because it makes communicating less anonymous. That's all :-)
About the formula:
So that would be:
(A:VELOCITY BODY X, knots) (A:AIRSPEED TRUE, knots)
/ 60 * int (>G:Var3)
08-01-2005, 08:39 PM
>I don't know anything about unnamed boards. Haven't seen any
>such directives at this site so hope I don't inadvertently
>break any rules.
LOL! It isn't a "rule" so much as an aversion of this site to naming the competition. Try entering the name directly and you'll see that the "profanity filter" will substitute ***** for what you typed... ;)
Sorry to hear about your login problem "over there." Hopefully it will be sorted out soon for you.
I believe Rob has answered your other question adequately, so I'll not recapitulate it... ;)
08-02-2005, 08:24 AM
Thanks, guys, for taking the time to share. With your help I've actually gotten bitmaps a'moving and numbers a'flashing.
One final question, please. Can you use one MaskImageName to work with two separate ImageName(s) inside the same Element? Or does each ImageName require its own mask inside its own Element? I can get the latter to work, but not the former.
08-02-2005, 10:34 AM
If these are two Images of which one is selected: yes, no problem.
See example of a Mask applied to a green or red bar.
<Position X="10" Y="10"/>
<MaskImage Name="BarMask123.bmp" ImageSizes="4,123"/>
<Case Value="0"> <Image Name="BarGreen.bmp"</Case>
<Case Value="1"> <Image Name="BarRed.bmp"</Case>
<Item Value="2.23" X="0" Y="0"/>
<Item Value="1.2" X="0" Y="102"/>
<Item Value="0.9" X="0" Y="123"/>
08-02-2005, 12:56 PM
Unfortunately both my images will be selected at the same time. Since both require identical masks, I've used the same mask with two names. Was hoping to cut down on file size by using one mask since I assume the xml is compiled with the bitmaps in some way by something inside FS.
Powered by vBulletin® Version 4.2.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.