Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: XML Simple

by Discipulus (Canon)
on Jun 01, 2015 at 08:33 UTC ( [id://1128529]=note: print w/replies, xml ) Need Help??


in reply to XML Simple

Welcome to Perl and to the monastery Arenas,

powershell is not a programming language, so you probably can profit from some basic reading about Perl as the book Beginning Perl or the (old but still usefull) Perl Cookbook.
Some sparse suggestion being you new to Perl and using winz: you can check if you have a Perl's module installed with a simple oneliner (take a look at perldoc about command line switches)
perl -MNot::Installed::Module -e "1"
You are executing (-e) an always-return-true mini Perl program (what is inside the doublequote) but loading some module (after the -M ) before runnig the code. You obviosly get:
Can't locate Not/Installed/Module.pm in @INC (@INC contains:...
You can install modules using the cpanp client (working in the strawberry Perl distro on which DWimPerl is built)
cpanp -i Not::Installed::Module
Choose carefully module to install and use: XML::Simple is simply deprecated. Other modules are better but you need to learn how to use them: the following, working, code uses XML::Twig for xml parsing: anyway, even if you use a good module, xml parsing is a little triky and shaggy thing.
#!perl use strict; use warnings; use XML::Twig; my $t= XML::Twig->new(pretty_print => 'indented', twig_handlers => { 'city/name'=>sub{ print $_[1]->text,"\n"; } +, 'city/population'=>sub{ print "Pop: ",$_[1] +->text,"\n"; }, } ); $t->parseurl('http://athome.myminicity.com/xml'); __OUTPUT__ AtHome Pop: 18998557

As last suggestion, when asking here at perlmonks, do your best to present a simple and fully understandable question, with code that reproduce the error you are facing, or being clear about data you have and data you want to get back from your program. Asking clear question let you to have in return good answers, sometimes real gems, lurking here very wise and experienced programmers (not me).

htH
L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^2: XML Simple
by karlgoethebier (Abbot) on Jun 07, 2015 at 07:47 UTC
    "powershell is not a programming language"

    I think the OP means Power Shell Scripting Language which is one.

    The inevitable example:

    [int]$i = 99; for($i=99; $i -gt 0; $i--) { write-host $i " bottles of beer on the wall"; write-host $i " bottles of beer"; write-host "Take one down, pass it around" write-host ($i-1) " bottles of beer on the wall" write-host "" }

    Please see also rosettacode and monad.

    Best regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

Re^2: XML Simple
by Arenas (Novice) on Jun 01, 2015 at 20:23 UTC

    Hello!

    Many thanks to all of your help!

    I will do: 'Choose carefully module'

    Impossible to download 'Number::Format'

    Probable my probleme is, I work with Vista 64

    @htH = Artist:

    I will also look for! => XML::Twig (great help!)

    This is transforment from powershell (excel) script => html. Now i will change and us GDI files

    http://arenas.pagesperso-orange.fr/mmc/simulation-athome-mmc.html

    All files togeter

    http://arenas.pagesperso-orange.fr/mmc/default-menu-Ville.html

    Greting

    @r

Re^2: XML Simple
by Arenas (Novice) on Jun 05, 2015 at 08:38 UTC

    Good Morning,

    I have reinstall perl (\Dwim), and only one version! So I m ready now.

    Please: How selecte singelnode nestet with Twig. and holdet by my $var =? (in the future so i can add math formula) (With Shell was : $xbcom = (xml$xdxml).selectSingleNode("city/bases/@com").$xt)

    How cleen variable: all or selective

    Thanks @r

    Nota bene:

    I don't was able to install "format number". Regex is good to do.

    my $VarNum = "14589965321"; # or "my $xbcom =" $ins =~ s/(\d)(?=(\d{3})+(?!\d))/$1 /g; print "$VarNum\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1128529]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (9)
As of 2024-04-18 15:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found