2011-12-22 - Perl scripts dealing with XML

addsrcs.pl - Add sources to a *.vcproj file
adjxml.pl - write the caption to a JetPhoto XML file as <info>...</info> use XML::DOM;
autosp01.pl my $xmlDoc = Win32::OLE->new('MSXML2.DOMDocument.3.0') or mydie( "new() failed" );
autoword02.pl - wdFormatXML - Extensible Markup Language (XML) format. 
autoword03b.pl
booksxml.pl - my $xmlDoc = Win32::OLE->new('MSXML2.DOMDocument.3.0') or mydie( "new() failed" );
chkaircraft.pl - $ss++ if ($item =~ /-set\.xml$/);
chkintlinks.pl - prt("$lnnm: potential end of XML tag pch=$pch ppch=$ppch\n") if ($show_comm_dbg);
chkrt.pl - my $dbg_out = 0;	# write the RE-LINED XML to a file
   sub reline_xml { sub xml_to_lines($$$) {
chkxml.pl - Given an XML file, test it - a SIMPLE test
cleanhtm02.pl - my %xmlblocks = (); show_xml_list( $clntxt );
cleanhtm03.pl - my %xmlblocks = (); my $xmlrange = ''; show_xml_list( $clntxt );
cmpvc8todsp.pl - my $dbg_srcv = 0;	# show XML version line xmlrpccpp.vcproj';
   sub get_xml_tag { process the XML project file (*.vcproj) and sub get_xml_sources {
cmpvcprojs.pl my @xlines1 = load_xml_lines( $val1 );
fg-ac.pl - 05/12/2010 - Update - move good functions to a 'lib_xml.pl'
   require 'lib_xml.pl' or die "Unable to load 'lib_xml.pl'! Check location and \@INC content.\n";
   #require "xmlgparse.pl" or die "ERROR: Unable to load xmlgparse.pl";
   sub scan_xml_text($$$) { my %xmlhash = ();
   push(@xmlarray, [ $eletyp, $xitem, $element, $pretxt, $bgnlnn, $stktxt ]);
fgchkaircraft.pl - my %h = process_aircraft_folder($in_folder);    # get LIST from ALL <aircraft>-set.xml files
fgscanvc-ok.pl - @lines = fg_xml_to_lines(\%lnmap, @lines);
                                            # PrecompiledHeaderFile=".\Debug\xmlrpccpp/xmlrpccpp.pch" 
                                            # AssemblerListingLocation=".\Debug\xmlrpccpp/" 
                                            # ObjectFile=".\Debug\xmlrpccpp/" 
                                            # ProgramDataBaseFileName=".\Debug\xmlrpccpp/" 
    sub xml_array_to_lines {
fgscanvc.pl - @lines = fg_xml_to_lines(\%lnmap, @lines);
                                            # PrecompiledHeaderFile=".\Debug\xmlrpccpp/xmlrpccpp.pch" 
                                            # AssemblerListingLocation=".\Debug\xmlrpccpp/" 
                                            # ObjectFile=".\Debug\xmlrpccpp/" 
                                            # ProgramDataBaseFileName=".\Debug\xmlrpccpp/" 
fgscanvc02.pl - @lines = fg_xml_to_lines(\%lnmap, @lines);
fgscanvc03.pl - @lines = fg_xml_to_lines(\%lnmap, @lines);
fgshowmaterials.pl - Very specific show of 'materials' defined in FG data 'materials.xml'
   my $in_file = "C:\\FG\\27\\data\\materials.xml"; sub trim_xml($) { # relinexml - 20090125
   sub xml_to_lines {
fgsln2dsw.pl - my @xml_tag_map = (); my @xml_lines = ();
   my @xml_line_map = ();  # multi - [ new_line, begin_line, end_line ]
   ##### VCPROJ XML PARSING #####
fgslnlist.pl - The general processing consists of reading the vcproj xml, and buidling a set of
    my $do_alternative_scan = 1;    # more extensive decode of VCPROJ XML
    ########### TRY FOR MORE DECODE OF THE XML #######
    ##### VCPROJ XML PARSING ##### sub get_xml_tag {
     push(@tagmap, [$xml, TT_DEC, 1]); push(@tagmap, [$xml, TT_END, 1]);
fgvc2dsp.pl - my @xml_tag_map = ();
fg_io_xml.pl - View the contents of a FlightGear IO XML file
   my $def_file = 'C:\DTEMP\FG\ivao\17\cfg\squawk.xml';
fg_menu_xml.pl - View the contents of a FlightGear IO XML file
   ###my $def_file = 'C:\FG\29\data\gui\dialogs\view.xml';
fg_server_xml2.pl - fg_server_xml.cgi: for FGMap # XML output, for FGMap
fg_signs.pl - $NUMSIGNS = $MAXNUMSIGNS = grep /\/sign\d+\.xml$/, ls($BASEDIR);
		exec("$FGFS --telnet=$PORT --config=$BASEDIR/signs.xml @fgfsargs");
fg_signs_test.pl - $NUMSIGNS = $MAXNUMSIGNS = grep /\/sign\d+\.xml$/, ls($BASEDIR);
    &log( $DEBUG, "Got $NUMSIGNS XML files ..." );
fixtitle.pl - specialized perl, to read a particular XML file,
    my $in_file = 'C:\Documents and Settings\Geoff McLane\My Documents\Louis\banan\myP2\BananAlbum.xml';
    ###my $in_file = 'Banan.xml';
foo.pl - use XML::Simple; my $file = 'foo.xml'; my $xs1 = XML::Simple->new(); my $doc = $xs1->XMLin($file);
glGet.pl - Specialised to process a glGet.xml, and produce a C table
    my $in_file = "C:\\DTEMP\\glGet.xml";
    sub process_xml_file($) {
imgalt02.pl - # studio.plist XML file ... each has to be inserted as 
    # Default JetPhoto configuration XML file ...
lib_vcscan.pl - # 2010/03/08 - Remove write tempvcx.xml from scanvc.pl, or only to perl base directory...
    sub svc_xml_to_lines($$);
lib_xml.pl - Gathering together useful 'xml' parsing functions
msvc8incs.pl - my $dbg_v02 = 0;    # show each XML lien - prt( "$xmlln: $line
    my %xml_hash = get_xml_file_hash($in_file, \%vc_hash);
    show_x_hash( \%xml_hash );
order.pl - use XML::XPath; my $xp = XML::XPath->new(filename => 'order.xml');
osm-gpx.pl - Read a *.gpx XML file, and list points
osm-load.pl - Load an XML OSM file
parse-xml.pl - My attempt at my OWN XML parser
parse-xml02.pl - My attempt at my OWN XML parser
parse-xml03.pl - My attempt at my OWN XML parser
    sub xml_set_hash_ref_value($$$$) {  sub xml_get_hash_ref_content($$) {
    sub xml_get_all_children($$$$) {
scanvc.pl - 2010/04/23 - handle different xml lining - added sub get_clean_seek_item($) to ensure trailing 
    '>' also removed
showpiperxml.pl  - VERY SPECIFIC - Quikc output of an XML file contents...
     my $def_file = 'C:\FG\27\data\Aircraft\pa24-250\help.xml';
showplayback.pl - SPECIFIC - Read the FG playback.xml, and show simple list of 'xml' chunks,
showsrcs.pl - my @xmllines = (); push(@xmllines, $aline); 
     print "Got $xlncnt XML lines ... $scnt file source lines ...\n";
showsrcs2.pl - my @xmllines = ();		push(@xmllines, $aline);
     prt( "Got $xlncnt XML lines ... $scnt file source lines ...\n" );
showsrcs3.pl - my @xmllines = ();my $xlncnt = scalar @xmllines;
     prt( "Got $xlncnt XML lines ... $scnt file source lines ...\n" );
shwplay.pl - my $def_file = 'C:\FG\27\data\Protocol\playback.xml';
     sub xml_sample() {
sitemap.pl - using XML::XPath. Presumes that the documents being 
     # searched are well-formed XML or XHTML. 
     use XML::XPath; use XML::XPath::XMLParser; use XML::Parser; my $ep = XML::Parser->new(Namespaces => 1); 
     my $xp = XML::XPath->new; my $root = XML::XPath::Node::Element->new('html'); my $body = XML::XPath::Node::Element->new('body');
sln2dsw.pl #my $defin = "C:\\FG\\FGCOMXML\\xmlrpc-c\\Windows\\xmlrpc.sln";
     my $dbg_srcv = 0;	# show XML version line
     ##### VCPROJ XML PARSING #####
    sub get_xml_tag { # process the XML project file (*.vcproj) and
    sub get_xml_sources {
sln2std.pl - sub get_full_xml_line($$$) {
     $fullline = get_full_xml_line(\$k,\@lines,$lncnt);
slnlist.pl - ##my $def_input = $base_dir."Windows\\xmlrpc.sln"; # adjust this to the file you want parsed
	 process_vcproj_xml_lines($line, @lns);
srtm-list.pl
test14.pl - my @xml_main = ();
vc8cmp-01.pl - my $dom1 = Win32::OLE->new('MSXML2.DOMDocument.3.0') or die "new() failed";
vc8cmp-02.pl  - my $dom1 = Win32::OLE->new('MSXML2.DOMDocument.3.0') or die "new() failed";
vc8srcs01.pl - # First try, using XML::Simple, so
    use XML::Simple; get_xml_sources($in_file);
 	my $xml = new XML::Simple;
vc8srcs02.pl - # First try, using XML::Simple, so use XML::Simple;
    # 20061128 - BUT XML::Simple IS NOT SO SIMPLE!!! See vc8scrs03.pl for try WITHOUT
    # NOTE: Reports - could not find ParserDetails.ini in C:/Perl/site/lib/XML/SAX
   sub get_xml_projects { # get_xml_source
vc8srcs03.pl - 		get_xml_projects($inp_file);
vcdelcfg.pl - my $debug_xml = 0; sub get_xml_hash($);
   sub show_xml_hash($) {  sub get_xml_line_from_hash($) {
vcfix.pl - sub get_xml_hash($);
vcproj03.pl - Parse a VCPROJ file - get_xml_source() is the service in sln2dsw.pl
vcproj05.pl - # 2010/03/08 - Remove write tempvcx.xml from scanvc.pl, or only to perl base directory...
    # 24/11/2010 - Support for VC10 XML files
vcprojlist.pl - my $xml = '';
xml01.pl - use XML::Simple; my $file = 'files/camelids.xml';
    my $xs1 = XML::Simple->new();
    my $doc = $xs1->XMLin($file);
xml02.pl - use XML::Simple; my $file = 'position.xml';
    my $xs1 = XML::Simple->new();
    my $doc = $xs1->XMLin($file);
xml03.pl - use XML::Simple; 
    my $xs1 = XML::Simple->new();
    my $doc = $xs1->XMLin($file);
xml04.pl - XML - Walking the xml document tree, using XML::Simple - 16 April, 2006
    use XML::Simple;
    my $xs1 = XML::Simple->new();
    my $doc = $xs1->XMLin($file);
xml05.pl - # XML - Walking the xml document tree, using XML::Simple - 17 April, 2006
    use XML::Simple; my $xs1 = XML::Simple->new();
    my $doc = $xs1->XMLin($file);
xml06.pl -  use XML::Simple;
    $xml = new XML::Simple (ForceArray => 1);
    $xml2 = new XML::Simple;
    $data = $xml->XMLin($raw);
xml07.pl - use XML::Simple;
    # $xml = new XML::Simple (ForceArray => 1);
    $xml2 = new XML::Simple;
    #$data2 = $xml2->XMLin($raw2);
xml08.pl - 2011-12-22 - Now working as it should.
    To explore the XML:Simple interface ...
    use XML::Simple;
    $xml2 = new XML::Simple;
    #$data2 = $xml2->XMLin($raw2);
xml2h01.pl  - Color code XML file data
    my $in_file = "temp1.xml";
xmldom01.pl - use XML::DOM; # perl -MCPAN -e shell 'install XML::DOM'
    # XML::Parser (At least version 2.28, 2.30 recommended) 
    my $parser = XML::DOM::Parser->new();
xmldom02.pl - Like xmldom01.pl, some more experiments with XML::DOM ...
    use XML::DOM;
    my $in_file = 'C:\FG\29\Atlas-0.4.9\projects\msvc\mapserv.xml';
    my $out_file = 'tempimagelist.xml';
    my $parser = XML::DOM::Parser->new();
xmlfgair.pl - h.cpan.org/dist/XML-Simple/lib/XML/Simple.pm
    use XML::Simple;
    my $def_file = 'C:\FG\27\data\Aircraft\A380\A380-set.xml';
xmlfgkey.pl  - use XML::Simple;
    my $file = 'C:/FG0981/FlightGear/data/keyboard.xml';
    my $xs1 = XML::Simple->new();
    my $doc = $xs1->XMLin($file);
xmlfgkey2.pl - use XML::Parser; use XML::SimpleObject;
    my $file = 'C:/FG0981/FlightGear/data/keyboard.xml';
    my $parser = XML::Parser->new(ErrorContext => 2, Style => "Tree");
    my $xso = XML::SimpleObject->new( $parser->parsefile($file) );
xmlfgkey3.pl -  use XML::Twig;
    my $file = 'C:/FGCVS/FlightGear/data/keyboard.xml';
    my $twig = XML::Twig->new();
xmlfix01.pl - Read an XML file, and add a title from the split of the file name
     use XML::Simple; my $in_file = 'Banan.xml';
     my $xml = XML::Simple->new(ForceArray => 1);
     my $data = $xml->XMLin($in_file);
xmlfix02.pl - use XML::Simple;
     $xs1 = new XML::Simple(keeproot => 1,searchpath => ".",
     $ref1 = $xs1->XMLin($in_file);
xmlgparse.pl - My attempt at my OWN XML parser
     my $xml_header   = "=XML HEADER=";
     #my $xml_comments = "=XML COMMENT=";
     my $xml_pathorder = "=XML PATHS=";
     # ### MY XML PARSER ###
xmllibxml01.pl use XML::LibXML; my $file = 'camelids01.xml';
     my $parser = XML::LibXML->new();
xmlreline.pl - Simple read and re-line an XML file input, write to output, if one given
xmlsax01.pl - use XML::Parser::PerlSAX; my $file = "camelids01.xml";
     my $parser = XML::Parser::PerlSAX->new(Handler => $handler);
xmlsaxmail01.pl - # Four popular modules do tree-based processing of XML with Perl, 
     # XML::Simple use XML::Parser::PerlSAX;
     my $parser = XML::Parser::PerlSAX->new(Handler => $handler);
     my $file = "mail.xml";
xmlsimple.pl - use XML::Simple;
     my $inp_xml_file = 'C:\FG\27\data\Aircraft\A380\A380-set.xml';
     prt( "Dump of [$in_xml_file]...\nNOT using (ForceArray => 1) ...\n" );
xmltwig01.pl - use XML::Twig; my $file = 'camelids01.xml'; my $twig = XML::Twig->new();
xmltwig02.pl - Using the XML::Twig interface, especially on VCPROJ files
    use XML::Twig;
	$file = 'C:/FGCVS/FlightGear/data/keyboard.xml';
	my $twig = XML::Twig->new(); my @groups = get_xml_groups($file);
	my @csrcs = get_xml_sources($file, $gp, 0); my $filter = get_xml_filter($file, $gp);
	my $t = XML::Twig->new();
	# THIS WORKS from: http://www.xmltwig.com/xmltwig/quick_ref.html
xmlwin32.pl - Parse an XML document using Win32::OLE ...
    # http://www.perl.com/pub/a/2001/04/17/msxml.html
    my $xml_file  = 'tempbooks.xml';
    prt( "Creating Win32::OLE MSXML2.DOMDocument.3.0 objects ...\n" );
    my $dom = Win32::OLE->new('MSXML2.DOMDocument.3.0') or mydie( "new() failed" );
    prt( "Loading $xml_file into DOM object ...\n" );
    $dom->Load($xml_file) or mydie( "Parse failed" );
xmlwrap02.pl - Exploring XML::Parser::Wrapper, loading from file ...
    use XML::Parser::Wrapper;
    my $parser = XML::Parser::Wrapper->new;
    my $root3 = $parser->parse({ file => 'books.xml' });
xmlwrap03.pl - Exploring XML::Parser::Wrapper, loading from file ...
    use XML::Parser::Wrapper;
    my $parser = XML::Parser::Wrapper->new;
xmlwrapper.pl - Test the XML::Parser::Wrapper interface ...
    # 2009/10/16 - Installed via PPM, XML-Parser-Wrapper, in DELL02... 
    use XML::Parser::Wrapper;
    my $xml_root = XML::Parser::Wrapper->new($xml); enumerate_elements($xml_root);
xml_test.pl -  warn "Usage: xml_test.pl [-d] testscript xmlfile\n";

