JupiterCrash has asked for the wisdom of the Perl Monks concerning the following question:

IIS has had, for a long time, kept its configuration in what it called the "MetaBase". This was a binary file in a not-very-open binary format that was difficuly to modify.

But Windows 2003 introduces IIS 6.0, which keeps all of this information in an XML file, MetaBase.xml, which is great. You can find it in \windows\system32\inetsrv\MetaBase.xml.

IIS 6.0 has a default (but configurable) property to NOT allow editing of this file while the server is running, and keeps a lock on it. But you can disable this property through IIS and edit the file while the server is live (it immediately brings in the changes, too!), or just shut down the IIS services and modify the file.

Has anyone used perl to modify any attributes of existing tags or add new ones? It's a very large XML file with many tags that have many attributes. I tried using XML::Simple, and it crashed at first when opening the file. For some reason, the XML file started off with three odd ascii characters. I removed them, and XML::Simple could then open the file. I was able to read then rewrite the file, but the re-written file was very different XML than I started off with. I must admit, I did not try and see if it worked.

I ended up not using a real XML parser, and just writing code to hack the changes I would need to make into the XML file manually.

But mostly what I was wondering (and here, finally is the question) is, has anyone had any success using perl and a XML parser to modify MetaBase.xml? If so, could you share some code?

And as a sidenote, what's your favorite XML parser for perl?

Replies are listed 'Best First'.
Re: Perl and IIS 6.0's MetaBase.xml
by bobn (Chaplain) on May 25, 2003 at 00:56 UTC
    XML::Simple isn't made for complicated parsing. It's intended for simple configuration files, and has a couple of tricks thrown in to help in this regard.

    I've used XML::Parser on my XML projects. I understand from subsequent reading that most consider that doing it the hard way, but it works for me.



    Bob Niederman, http://bob-n.com
Re: Perl and IIS 6.0's MetaBase.xml
by gmpassos (Priest) on May 24, 2003 at 19:59 UTC
    Maybe the problem is to parse the file? Have you tried to make a copy (just to other location) of the XML file and work with it, just to see if work?

    Since the problem, I think, is to parse, I can't say anything before see the file. Can you post the file, or some part? Or put it in some site?

    Graciliano M. P.
    "The creativity is the expression of the liberty".

Re: Perl and IIS 6.0's MetaBase.xml
by meredith (Friar) on May 25, 2003 at 21:01 UTC
    Another question with this particular file is whether or not IIS is using the MSXML parser or an ad-hoc parser, if it is the MSXML parser, it shouldn't have any issues with your output (assuming valid xml), but if they patched something together, watch out!

    mhoward - at - hattmoward.org