XML::Writer::Simple

Alberto Simões
Alberto SimõesTeacher, programmer at University of Minho
XML::Writer::Simple

                  Alberto Sim˜es
                             o
                  ambs@cpan.org


      Portuguese Perl Workshop 2008




Alberto Sim˜es ambs@cpan.org
           o                   XML::Writer::Simple
Why?




XML wasn’t designed to be written manually;
So, we normally generate XML;
But then, we need to write it          (in programs)

And we do not want to do that!




        Alberto Sim˜es ambs@cpan.org
                   o                    XML::Writer::Simple
Typical Java Code




System.out.println(quot; <agenda>quot;);
while(contact.next()) {
  System.out.println(quot;<contact>quot;);
  System.out.println(quot; <name>quot;+contact.name()+quot;</name>quot;);
  System.out.println(quot; <email>quot;+contact.mail()+quot;</email>quot;);
  System.out.println(quot; <tel>quot;+contact.tel()+quot;</tel>quot;);
  System.out.println(quot;</contact>quot;);
}
System.out.println(quot; </agenda>quot;);




           Alberto Sim˜es ambs@cpan.org
                      o                   XML::Writer::Simple
Possible Perl code




print quot; <agenda>nquot;;
for $contact (@contacts) {
  print quot;<contact>nquot;;
  print quot; <name>$contact->{name}</name>nquot;;
  print quot; <email>$contact->{mail}</email>nquot;;
  print quot; <tel>$contact->{tel}</tel>nquot;;
  print quot;</contact>nquot;;
}
print quot; </agenda>nquot;;




           Alberto Sim˜es ambs@cpan.org
                      o                   XML::Writer::Simple
Using XML::Writer::Simple




  print agenda(
     map { contact(
              name($_->{name}),
              email($_->{mail}),
              tel($_->{tel})) } @contacts )
Yeah, stolen from CGI!




            Alberto Sim˜es ambs@cpan.org
                       o                   XML::Writer::Simple
What tags to use?




we want a function for each tag:
    easy for HTML!
and for XML?
    what are the valid tags?
    who tell us?




        Alberto Sim˜es ambs@cpan.org
                   o                   XML::Writer::Simple
Full XML::Writer::Simple example




use XML::Writer::Simple
    tags => [qw/agenda contact name email tel/];

print agenda(
   map { contact(
            name($_->{name}),
            email($_->{mail}),
            tel($_->{tel})) } @contacts )




         Alberto Sim˜es ambs@cpan.org
                    o                   XML::Writer::Simple
Full XML::Writer::Simple example using a DTD




use XML::Writer::Simple
    dtd => quot;agenda.dtdquot;;

print agenda(
   map { contact(
            name($_->{name}),
            email($_->{mail}),
            tel($_->{tel})) } @contacts )




         Alberto Sim˜es ambs@cpan.org
                    o                   XML::Writer::Simple
Full XML::Writer::Simple example using a sample file




use XML::Writer::Simple
    xml => [qw/mycontacts.xml morecontacts.xml/];

print agenda(
   map { contact(
            name($_->{name}),
            email($_->{mail}),
            tel($_->{tel})) } @contacts )




         Alberto Sim˜es ambs@cpan.org
                    o                   XML::Writer::Simple
And about attributes?


  they do not need to be declared!
  just use them as you would under CGI.
  that is, use as first parameter an hash reference.



use XML::Writer::Simple
    xml => [qw/mycontacts.xml morecontacts.xml/];

print agenda(
   map { contact( { owner => quot;ambs@di.uminho.ptquot; },
            name($_->{name}),
            email($_->{mail}),
            tel($_->{tel})) } @contacts )



          Alberto Sim˜es ambs@cpan.org
                     o                   XML::Writer::Simple
And more! PowerTags



PowerTags:
    apply more than one XML tag;
    follow the Perl data structure;
PowerTag by example:
    ul_li(quot;aquot;,quot;bquot;,quot;cquot;)
         <ul><li>a</li><li>b</li><li>c</li></ul>
    ul_li({attr=>quot;valquot;},quot;aquot;,quot;bquot;)
         <ul attr=quot;valquot;><li>a</li><li>b</li></ul>
or yet...
table_tr_td( [quot;aquot;,quot;bquot;,quot;cquot;],[quot;dquot;,quot;equot;,quot;fquot;] );




        Alberto Sim˜es ambs@cpan.org
                   o                   XML::Writer::Simple
PowerTags — How to define them?




n levels;
Can be declared...
       use XML::Writer::Simple
           powertags=>[qw/ul_li ol_li/];
Can be created in runtime...
       powertag(quot;tablequot;,quot;trquot;,quot;tdquot;);




            Alberto Sim˜es ambs@cpan.org
                       o                   XML::Writer::Simple
Five Minutes Yet?




Alberto Sim˜es ambs@cpan.org
           o                   XML::Writer::Simple
1 of 13

Recommended

Hunter.io scraper by
Hunter.io scraperHunter.io scraper
Hunter.io scraperMamoon Ismail Khalid
509 views3 slides
Easy Blogging With Emacs -- Cheatsheet by
Easy Blogging With Emacs -- CheatsheetEasy Blogging With Emacs -- Cheatsheet
Easy Blogging With Emacs -- CheatsheetDashamir Hoxha
666 views1 slide
Import data from csv excel file and export to xml excel file in c programming by
Import data from csv excel file and export to xml excel file in c programmingImport data from csv excel file and export to xml excel file in c programming
Import data from csv excel file and export to xml excel file in c programmingSalar Delavar Qashqai
42 views7 slides
Building your apps for cross platform compatability by
Building your apps for cross platform compatabilityBuilding your apps for cross platform compatability
Building your apps for cross platform compatabilityMichael Cummings
474 views29 slides
symfony & jQuery (PUG) by
symfony & jQuery (PUG)symfony & jQuery (PUG)
symfony & jQuery (PUG)Massimiliano Arione
703 views19 slides
Print input-presentation by
Print input-presentationPrint input-presentation
Print input-presentationMartin McBride
682 views45 slides

More Related Content

Viewers also liked

Fisac Varese Informa il numero di Ottobre 2012 - In piazza ed altro by
Fisac Varese Informa il numero di Ottobre 2012 - In piazza ed altroFisac Varese Informa il numero di Ottobre 2012 - In piazza ed altro
Fisac Varese Informa il numero di Ottobre 2012 - In piazza ed altroFisac-Cgil Varese
258 views7 slides
Alerta epidemiologicano1 2015meningitismeningococica by
Alerta epidemiologicano1 2015meningitismeningococicaAlerta epidemiologicano1 2015meningitismeningococica
Alerta epidemiologicano1 2015meningitismeningococicaEpidemiologia Hospital Sergio E. Bernales
408 views3 slides
Pikondoa by
PikondoaPikondoa
Pikondoamikelzubia
355 views6 slides
El próximo escenario global by
El próximo escenario global El próximo escenario global
El próximo escenario global Al Cougar
2.4K views22 slides
Roljic_Lazo-Karton_naucnog_radnika-februar__2016 by
Roljic_Lazo-Karton_naucnog_radnika-februar__2016Roljic_Lazo-Karton_naucnog_radnika-februar__2016
Roljic_Lazo-Karton_naucnog_radnika-februar__2016Lazo Roljic
604 views14 slides
August 2011 The Business Value of Office 365 for SharePoint users by
August 2011 The Business Value of Office 365 for SharePoint usersAugust 2011 The Business Value of Office 365 for SharePoint users
August 2011 The Business Value of Office 365 for SharePoint usersKnowledge Management Associates, LLC
622 views37 slides

Viewers also liked(20)

Fisac Varese Informa il numero di Ottobre 2012 - In piazza ed altro by Fisac-Cgil Varese
Fisac Varese Informa il numero di Ottobre 2012 - In piazza ed altroFisac Varese Informa il numero di Ottobre 2012 - In piazza ed altro
Fisac Varese Informa il numero di Ottobre 2012 - In piazza ed altro
Fisac-Cgil Varese258 views
El próximo escenario global by Al Cougar
El próximo escenario global El próximo escenario global
El próximo escenario global
Al Cougar 2.4K views
Roljic_Lazo-Karton_naucnog_radnika-februar__2016 by Lazo Roljic
Roljic_Lazo-Karton_naucnog_radnika-februar__2016Roljic_Lazo-Karton_naucnog_radnika-februar__2016
Roljic_Lazo-Karton_naucnog_radnika-februar__2016
Lazo Roljic604 views
Usabilidad Convertibilidad 3 by Iñaki Lakarra
Usabilidad Convertibilidad 3Usabilidad Convertibilidad 3
Usabilidad Convertibilidad 3
Iñaki Lakarra473 views
Abusive Registration And Use Of Domain Names by iptwins1
Abusive Registration And Use Of Domain NamesAbusive Registration And Use Of Domain Names
Abusive Registration And Use Of Domain Names
iptwins1607 views
C:\Documents And Settings\Usuario\Escritorio\La Aventura De Apender by David Zarza
C:\Documents And Settings\Usuario\Escritorio\La Aventura De ApenderC:\Documents And Settings\Usuario\Escritorio\La Aventura De Apender
C:\Documents And Settings\Usuario\Escritorio\La Aventura De Apender
David Zarza278 views
Tema De Dominio Tcp Ip Version 1 Final by mariasusanaSD
Tema De Dominio Tcp Ip Version 1 FinalTema De Dominio Tcp Ip Version 1 Final
Tema De Dominio Tcp Ip Version 1 Final
mariasusanaSD928 views
Libro de la fundacion de El Pueblo de El Progreso Piaxtla Puebla 2013 by Sing Your Name
Libro de la fundacion de El Pueblo de El Progreso Piaxtla Puebla 2013Libro de la fundacion de El Pueblo de El Progreso Piaxtla Puebla 2013
Libro de la fundacion de El Pueblo de El Progreso Piaxtla Puebla 2013
Sing Your Name8.8K views
Collar y Brazalete Marquesa de Nikken by NIKKEN Perú
Collar y Brazalete Marquesa de NikkenCollar y Brazalete Marquesa de Nikken
Collar y Brazalete Marquesa de Nikken
NIKKEN Perú503 views
Hoy es el primer día de tu nueva vida / Inguralde / Equiliqua 30oct13 by Juanjo Brizuela
Hoy es el primer día de tu nueva vida / Inguralde / Equiliqua 30oct13Hoy es el primer día de tu nueva vida / Inguralde / Equiliqua 30oct13
Hoy es el primer día de tu nueva vida / Inguralde / Equiliqua 30oct13
Juanjo Brizuela4.9K views
La foto de un autor regional by 51976122
La foto de un autor regionalLa foto de un autor regional
La foto de un autor regional
51976122864 views
Az web company profiling example by frankpaul_con
Az web   company profiling exampleAz web   company profiling example
Az web company profiling example
frankpaul_con430 views
NY EDEN for Municipal Clerks - Cornell Clerks institute 2015 by Keith G. Tidball
NY EDEN for Municipal Clerks - Cornell Clerks institute 2015 NY EDEN for Municipal Clerks - Cornell Clerks institute 2015
NY EDEN for Municipal Clerks - Cornell Clerks institute 2015
Keith G. Tidball2.4K views

Similar to XML::Writer::Simple

Lecture 4 - Comm Lab: Web @ ITP by
Lecture 4 - Comm Lab: Web @ ITPLecture 4 - Comm Lab: Web @ ITP
Lecture 4 - Comm Lab: Web @ ITPyucefmerhi
299 views44 slides
My First Rails Plugin - Usertext by
My First Rails Plugin - UsertextMy First Rails Plugin - Usertext
My First Rails Plugin - Usertextfrankieroberto
696 views48 slides
Malli: inside data-driven schemas by
Malli: inside data-driven schemasMalli: inside data-driven schemas
Malli: inside data-driven schemasMetosin Oy
1K views56 slides
The Real Time Web with XMPP by
The Real Time Web with XMPPThe Real Time Web with XMPP
The Real Time Web with XMPPJack Moffitt
14.1K views123 slides
C to perl binding by
C to perl bindingC to perl binding
C to perl bindingShmuel Fomberg
2.5K views41 slides
And now you have two problems. Ruby regular expressions for fun and profit by... by
And now you have two problems. Ruby regular expressions for fun and profit by...And now you have two problems. Ruby regular expressions for fun and profit by...
And now you have two problems. Ruby regular expressions for fun and profit by...Codemotion
989 views27 slides

Similar to XML::Writer::Simple(20)

Lecture 4 - Comm Lab: Web @ ITP by yucefmerhi
Lecture 4 - Comm Lab: Web @ ITPLecture 4 - Comm Lab: Web @ ITP
Lecture 4 - Comm Lab: Web @ ITP
yucefmerhi299 views
My First Rails Plugin - Usertext by frankieroberto
My First Rails Plugin - UsertextMy First Rails Plugin - Usertext
My First Rails Plugin - Usertext
frankieroberto696 views
Malli: inside data-driven schemas by Metosin Oy
Malli: inside data-driven schemasMalli: inside data-driven schemas
Malli: inside data-driven schemas
Metosin Oy1K views
The Real Time Web with XMPP by Jack Moffitt
The Real Time Web with XMPPThe Real Time Web with XMPP
The Real Time Web with XMPP
Jack Moffitt14.1K views
And now you have two problems. Ruby regular expressions for fun and profit by... by Codemotion
And now you have two problems. Ruby regular expressions for fun and profit by...And now you have two problems. Ruby regular expressions for fun and profit by...
And now you have two problems. Ruby regular expressions for fun and profit by...
Codemotion989 views
Beginning Scala Svcc 2009 by David Pollak
Beginning Scala Svcc 2009Beginning Scala Svcc 2009
Beginning Scala Svcc 2009
David Pollak855 views
C++11 - A Change in Style - v2.0 by Yaser Zhian
C++11 - A Change in Style - v2.0C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0
Yaser Zhian1K views
iRODS Rule Language Cheat Sheet by Samuel Lampa
iRODS Rule Language Cheat SheetiRODS Rule Language Cheat Sheet
iRODS Rule Language Cheat Sheet
Samuel Lampa2.9K views
Os Fetterupdated by oscon2007
Os FetterupdatedOs Fetterupdated
Os Fetterupdated
oscon2007245 views
What you forgot from your Computer Science Degree by Stephen Darlington
What you forgot from your Computer Science DegreeWhat you forgot from your Computer Science Degree
What you forgot from your Computer Science Degree
Stephen Darlington2.5K views
Scala + WattzOn, sitting in a tree.... by Raffi Krikorian
Scala + WattzOn, sitting in a tree....Scala + WattzOn, sitting in a tree....
Scala + WattzOn, sitting in a tree....
Raffi Krikorian1.6K views
Scala 2 + 2 > 4 by Emil Vladev
Scala 2 + 2 > 4Scala 2 + 2 > 4
Scala 2 + 2 > 4
Emil Vladev1.4K views
XML processing with perl by Joe Jiang
XML processing with perlXML processing with perl
XML processing with perl
Joe Jiang927 views
Linq 090701233237 Phpapp01 by google
Linq 090701233237 Phpapp01Linq 090701233237 Phpapp01
Linq 090701233237 Phpapp01
google323 views
The bones of a nice Python script by saniac
The bones of a nice Python scriptThe bones of a nice Python script
The bones of a nice Python script
saniac2.9K views

More from Alberto Simões

Source Code Quality by
Source Code QualitySource Code Quality
Source Code QualityAlberto Simões
1.6K views61 slides
Language Identification: A neural network approach by
Language Identification: A neural network approachLanguage Identification: A neural network approach
Language Identification: A neural network approachAlberto Simões
2.2K views40 slides
Google Maps JS API by
Google Maps JS APIGoogle Maps JS API
Google Maps JS APIAlberto Simões
2.5K views55 slides
Making the most of a 100-year-old dictionary by
Making the most of a 100-year-old dictionaryMaking the most of a 100-year-old dictionary
Making the most of a 100-year-old dictionaryAlberto Simões
1.5K views42 slides
Dictionary Alignment by Rewrite-based Entry Translation by
Dictionary Alignment by Rewrite-based Entry TranslationDictionary Alignment by Rewrite-based Entry Translation
Dictionary Alignment by Rewrite-based Entry TranslationAlberto Simões
903 views23 slides
EMLex-A5: Specialized Dictionaries by
EMLex-A5: Specialized DictionariesEMLex-A5: Specialized Dictionaries
EMLex-A5: Specialized DictionariesAlberto Simões
2.9K views150 slides

More from Alberto Simões(20)

Language Identification: A neural network approach by Alberto Simões
Language Identification: A neural network approachLanguage Identification: A neural network approach
Language Identification: A neural network approach
Alberto Simões2.2K views
Making the most of a 100-year-old dictionary by Alberto Simões
Making the most of a 100-year-old dictionaryMaking the most of a 100-year-old dictionary
Making the most of a 100-year-old dictionary
Alberto Simões1.5K views
Dictionary Alignment by Rewrite-based Entry Translation by Alberto Simões
Dictionary Alignment by Rewrite-based Entry TranslationDictionary Alignment by Rewrite-based Entry Translation
Dictionary Alignment by Rewrite-based Entry Translation
Alberto Simões903 views
EMLex-A5: Specialized Dictionaries by Alberto Simões
EMLex-A5: Specialized DictionariesEMLex-A5: Specialized Dictionaries
EMLex-A5: Specialized Dictionaries
Alberto Simões2.9K views
Aula 04 - Introdução aos Diagramas de Sequência by Alberto Simões
Aula 04 - Introdução aos Diagramas de SequênciaAula 04 - Introdução aos Diagramas de Sequência
Aula 04 - Introdução aos Diagramas de Sequência
Alberto Simões1.2K views
Aula 03 - Introdução aos Diagramas de Atividade by Alberto Simões
Aula 03 - Introdução aos Diagramas de AtividadeAula 03 - Introdução aos Diagramas de Atividade
Aula 03 - Introdução aos Diagramas de Atividade
Alberto Simões3.8K views
Aula 02 - Engenharia de Requisitos by Alberto Simões
Aula 02 - Engenharia de RequisitosAula 02 - Engenharia de Requisitos
Aula 02 - Engenharia de Requisitos
Alberto Simões1.6K views
Aula 01 - Planeamento de Sistemas de Informação by Alberto Simões
Aula 01 - Planeamento de Sistemas de InformaçãoAula 01 - Planeamento de Sistemas de Informação
Aula 01 - Planeamento de Sistemas de Informação
Alberto Simões4.4K views
Building C and C++ libraries with Perl by Alberto Simões
Building C and C++ libraries with PerlBuilding C and C++ libraries with Perl
Building C and C++ libraries with Perl
Alberto Simões1.6K views
Processing XML: a rewriting system approach by Alberto Simões
Processing XML: a rewriting system approachProcessing XML: a rewriting system approach
Processing XML: a rewriting system approach
Alberto Simões854 views
Arquitecturas de Tradução Automática by Alberto Simões
Arquitecturas de Tradução AutomáticaArquitecturas de Tradução Automática
Arquitecturas de Tradução Automática
Alberto Simões751 views

Recently uploaded

DRBD Deep Dive - Philipp Reisner - LINBIT by
DRBD Deep Dive - Philipp Reisner - LINBITDRBD Deep Dive - Philipp Reisner - LINBIT
DRBD Deep Dive - Philipp Reisner - LINBITShapeBlue
140 views21 slides
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue by
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlueCloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlueShapeBlue
93 views15 slides
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ... by
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...ShapeBlue
79 views17 slides
NTGapps NTG LowCode Platform by
NTGapps NTG LowCode Platform NTGapps NTG LowCode Platform
NTGapps NTG LowCode Platform Mustafa Kuğu
365 views30 slides
20231123_Camunda Meetup Vienna.pdf by
20231123_Camunda Meetup Vienna.pdf20231123_Camunda Meetup Vienna.pdf
20231123_Camunda Meetup Vienna.pdfPhactum Softwareentwicklung GmbH
50 views73 slides
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ... by
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...ShapeBlue
85 views10 slides

Recently uploaded(20)

DRBD Deep Dive - Philipp Reisner - LINBIT by ShapeBlue
DRBD Deep Dive - Philipp Reisner - LINBITDRBD Deep Dive - Philipp Reisner - LINBIT
DRBD Deep Dive - Philipp Reisner - LINBIT
ShapeBlue140 views
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue by ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlueCloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
ShapeBlue93 views
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ... by ShapeBlue
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
ShapeBlue79 views
NTGapps NTG LowCode Platform by Mustafa Kuğu
NTGapps NTG LowCode Platform NTGapps NTG LowCode Platform
NTGapps NTG LowCode Platform
Mustafa Kuğu365 views
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ... by ShapeBlue
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...
ShapeBlue85 views
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue by ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
ShapeBlue103 views
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T by ShapeBlue
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&TCloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
ShapeBlue112 views
Extending KVM Host HA for Non-NFS Storage - Alex Ivanov - StorPool by ShapeBlue
Extending KVM Host HA for Non-NFS Storage -  Alex Ivanov - StorPoolExtending KVM Host HA for Non-NFS Storage -  Alex Ivanov - StorPool
Extending KVM Host HA for Non-NFS Storage - Alex Ivanov - StorPool
ShapeBlue84 views
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online by ShapeBlue
KVM Security Groups Under the Hood - Wido den Hollander - Your.OnlineKVM Security Groups Under the Hood - Wido den Hollander - Your.Online
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online
ShapeBlue181 views
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by Bernd Ruecker
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
Bernd Ruecker50 views
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O... by ShapeBlue
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...
ShapeBlue88 views
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda... by ShapeBlue
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
ShapeBlue120 views
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R... by ShapeBlue
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...
ShapeBlue132 views
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by James Anderson
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
James Anderson156 views
"Surviving highload with Node.js", Andrii Shumada by Fwdays
"Surviving highload with Node.js", Andrii Shumada "Surviving highload with Node.js", Andrii Shumada
"Surviving highload with Node.js", Andrii Shumada
Fwdays53 views
Digital Personal Data Protection (DPDP) Practical Approach For CISOs by Priyanka Aash
Digital Personal Data Protection (DPDP) Practical Approach For CISOsDigital Personal Data Protection (DPDP) Practical Approach For CISOs
Digital Personal Data Protection (DPDP) Practical Approach For CISOs
Priyanka Aash153 views
The Role of Patterns in the Era of Large Language Models by Yunyao Li
The Role of Patterns in the Era of Large Language ModelsThe Role of Patterns in the Era of Large Language Models
The Role of Patterns in the Era of Large Language Models
Yunyao Li80 views

XML::Writer::Simple

  • 1. XML::Writer::Simple Alberto Sim˜es o ambs@cpan.org Portuguese Perl Workshop 2008 Alberto Sim˜es ambs@cpan.org o XML::Writer::Simple
  • 2. Why? XML wasn’t designed to be written manually; So, we normally generate XML; But then, we need to write it (in programs) And we do not want to do that! Alberto Sim˜es ambs@cpan.org o XML::Writer::Simple
  • 3. Typical Java Code System.out.println(quot; <agenda>quot;); while(contact.next()) { System.out.println(quot;<contact>quot;); System.out.println(quot; <name>quot;+contact.name()+quot;</name>quot;); System.out.println(quot; <email>quot;+contact.mail()+quot;</email>quot;); System.out.println(quot; <tel>quot;+contact.tel()+quot;</tel>quot;); System.out.println(quot;</contact>quot;); } System.out.println(quot; </agenda>quot;); Alberto Sim˜es ambs@cpan.org o XML::Writer::Simple
  • 4. Possible Perl code print quot; <agenda>nquot;; for $contact (@contacts) { print quot;<contact>nquot;; print quot; <name>$contact->{name}</name>nquot;; print quot; <email>$contact->{mail}</email>nquot;; print quot; <tel>$contact->{tel}</tel>nquot;; print quot;</contact>nquot;; } print quot; </agenda>nquot;; Alberto Sim˜es ambs@cpan.org o XML::Writer::Simple
  • 5. Using XML::Writer::Simple print agenda( map { contact( name($_->{name}), email($_->{mail}), tel($_->{tel})) } @contacts ) Yeah, stolen from CGI! Alberto Sim˜es ambs@cpan.org o XML::Writer::Simple
  • 6. What tags to use? we want a function for each tag: easy for HTML! and for XML? what are the valid tags? who tell us? Alberto Sim˜es ambs@cpan.org o XML::Writer::Simple
  • 7. Full XML::Writer::Simple example use XML::Writer::Simple tags => [qw/agenda contact name email tel/]; print agenda( map { contact( name($_->{name}), email($_->{mail}), tel($_->{tel})) } @contacts ) Alberto Sim˜es ambs@cpan.org o XML::Writer::Simple
  • 8. Full XML::Writer::Simple example using a DTD use XML::Writer::Simple dtd => quot;agenda.dtdquot;; print agenda( map { contact( name($_->{name}), email($_->{mail}), tel($_->{tel})) } @contacts ) Alberto Sim˜es ambs@cpan.org o XML::Writer::Simple
  • 9. Full XML::Writer::Simple example using a sample file use XML::Writer::Simple xml => [qw/mycontacts.xml morecontacts.xml/]; print agenda( map { contact( name($_->{name}), email($_->{mail}), tel($_->{tel})) } @contacts ) Alberto Sim˜es ambs@cpan.org o XML::Writer::Simple
  • 10. And about attributes? they do not need to be declared! just use them as you would under CGI. that is, use as first parameter an hash reference. use XML::Writer::Simple xml => [qw/mycontacts.xml morecontacts.xml/]; print agenda( map { contact( { owner => quot;ambs@di.uminho.ptquot; }, name($_->{name}), email($_->{mail}), tel($_->{tel})) } @contacts ) Alberto Sim˜es ambs@cpan.org o XML::Writer::Simple
  • 11. And more! PowerTags PowerTags: apply more than one XML tag; follow the Perl data structure; PowerTag by example: ul_li(quot;aquot;,quot;bquot;,quot;cquot;) <ul><li>a</li><li>b</li><li>c</li></ul> ul_li({attr=>quot;valquot;},quot;aquot;,quot;bquot;) <ul attr=quot;valquot;><li>a</li><li>b</li></ul> or yet... table_tr_td( [quot;aquot;,quot;bquot;,quot;cquot;],[quot;dquot;,quot;equot;,quot;fquot;] ); Alberto Sim˜es ambs@cpan.org o XML::Writer::Simple
  • 12. PowerTags — How to define them? n levels; Can be declared... use XML::Writer::Simple powertags=>[qw/ul_li ol_li/]; Can be created in runtime... powertag(quot;tablequot;,quot;trquot;,quot;tdquot;); Alberto Sim˜es ambs@cpan.org o XML::Writer::Simple
  • 13. Five Minutes Yet? Alberto Sim˜es ambs@cpan.org o XML::Writer::Simple