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

I have been trying to edit vcproj files in VS2008 using perl. My intention is to edit the "default" project settings that are not visible while editing the .vcproj file from a text editor. I have a perl script that uses XML::Simple to read and write the project settings information. But the issue found here is that the visual studio 2008 IDE fails to recognise the newly generated .vcproj via this xml method. Can anyone please suggest what could be useful way of editing the default project settings in .vcproj using perl script as I need to edit lot many project files via this method? Thanks!

Replies are listed 'Best First'.
Re: editing .vcproj files using perl.
by mr_mischief (Monsignor) on Jul 15, 2009 at 19:04 UTC

    There's a good chance that although the file itself is well-formed and valid XML that the applications using it are not getting their data from it via names but from the order of the entities. XML::Simple does not maintain the order of entities in the XML it reads and emits -- only the parent-child relationship of the tree is maintained. If you need to deal with a closed-source application that reads XML and cares anything about the ordering of child nodes of a particular parent, you'll need some XML tool that maintains that order.

    Various monks will line up for caucus behind XML::Twig, XML::LibXML, XML::XPath, XML::DOM, XML::SAX, and more. Probably the best thing you can do is search the monastery (using super search or using a Yahoo or Google site-specific search perhaps) for XML module information to get the pros and cons of the different modules.

    XML::Simple isn't just simple to use, but it's also kept simple in concept by idealizing XML. That's an ideal many packages don't follow, and you'll need a solution that deals better with those additional constraints on certain XML documents. Whether the order of child nodes in an XML document should matter is a deeper and more philosophical issue which won't do much good to argue. Other software developers are putting out code which expects certain nodes in a certain order, and you have to deal with it if you want to produce XML they will properly parse. I would caution you not to take their example if you decide to use XML for your own configuration files, but you're probably not going to change their minds about what's proper for their projects.