SlideShare una empresa de Scribd logo
1 de 13
Descargar para leer sin conexión
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

Más contenido relacionado

Destacado

Roljic_Lazo-Karton_naucnog_radnika-februar__2016
Roljic_Lazo-Karton_naucnog_radnika-februar__2016Roljic_Lazo-Karton_naucnog_radnika-februar__2016
Roljic_Lazo-Karton_naucnog_radnika-februar__2016
Lazo Roljic
 
Usabilidad Convertibilidad 3
Usabilidad Convertibilidad 3Usabilidad Convertibilidad 3
Usabilidad Convertibilidad 3
Iñaki Lakarra
 
Abusive Registration And Use Of Domain Names
Abusive Registration And Use Of Domain NamesAbusive Registration And Use Of Domain Names
Abusive Registration And Use Of Domain Names
iptwins1
 
C:\Documents And Settings\Usuario\Escritorio\La Aventura De Apender
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 Zarza
 
Tema De Dominio Tcp Ip Version 1 Final
Tema De Dominio Tcp Ip Version 1 FinalTema De Dominio Tcp Ip Version 1 Final
Tema De Dominio Tcp Ip Version 1 Final
mariasusanaSD
 
La foto de un autor regional
La foto de un autor regionalLa foto de un autor regional
La foto de un autor regional
51976122
 

Destacado (20)

Fisac Varese Informa il numero di Ottobre 2012 - In piazza ed altro
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
 
Alerta epidemiologicano1 2015meningitismeningococica
Alerta epidemiologicano1 2015meningitismeningococicaAlerta epidemiologicano1 2015meningitismeningococica
Alerta epidemiologicano1 2015meningitismeningococica
 
Pikondoa
PikondoaPikondoa
Pikondoa
 
El próximo escenario global
El próximo escenario global El próximo escenario global
El próximo escenario global
 
Roljic_Lazo-Karton_naucnog_radnika-februar__2016
Roljic_Lazo-Karton_naucnog_radnika-februar__2016Roljic_Lazo-Karton_naucnog_radnika-februar__2016
Roljic_Lazo-Karton_naucnog_radnika-februar__2016
 
August 2011 The Business Value of Office 365 for SharePoint users
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 users
 
Alv funciones
Alv   funcionesAlv   funciones
Alv funciones
 
Usabilidad Convertibilidad 3
Usabilidad Convertibilidad 3Usabilidad Convertibilidad 3
Usabilidad Convertibilidad 3
 
Abusive Registration And Use Of Domain Names
Abusive Registration And Use Of Domain NamesAbusive Registration And Use Of Domain Names
Abusive Registration And Use Of Domain Names
 
deber laboratorio
deber laboratoriodeber laboratorio
deber laboratorio
 
C:\Documents And Settings\Usuario\Escritorio\La Aventura De Apender
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
 
Tema De Dominio Tcp Ip Version 1 Final
Tema De Dominio Tcp Ip Version 1 FinalTema De Dominio Tcp Ip Version 1 Final
Tema De Dominio Tcp Ip Version 1 Final
 
Libro de la fundacion de El Pueblo de El Progreso Piaxtla Puebla 2013
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
 
Collar y Brazalete Marquesa de Nikken
Collar y Brazalete Marquesa de NikkenCollar y Brazalete Marquesa de Nikken
Collar y Brazalete Marquesa de Nikken
 
EACS Newsletter 2013
EACS Newsletter 2013EACS Newsletter 2013
EACS Newsletter 2013
 
Hoy es el primer día de tu nueva vida / Inguralde / Equiliqua 30oct13
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
 
La foto de un autor regional
La foto de un autor regionalLa foto de un autor regional
La foto de un autor regional
 
Az web company profiling example
Az web   company profiling exampleAz web   company profiling example
Az web company profiling example
 
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
NY EDEN for Municipal Clerks - Cornell Clerks institute 2015
 
Sevillajs: Una tarde con Firefox OS
Sevillajs: Una tarde con Firefox OSSevillajs: Una tarde con Firefox OS
Sevillajs: Una tarde con Firefox OS
 

Similar a XML::Writer::Simple

Lecture 4 - Comm Lab: Web @ ITP
Lecture 4 - Comm Lab: Web @ ITPLecture 4 - Comm Lab: Web @ ITP
Lecture 4 - Comm Lab: Web @ ITP
yucefmerhi
 
JavaScript and jQuery Fundamentals
JavaScript and jQuery FundamentalsJavaScript and jQuery Fundamentals
JavaScript and jQuery Fundamentals
BG Java EE Course
 
Os Fetterupdated
Os FetterupdatedOs Fetterupdated
Os Fetterupdated
oscon2007
 
XML processing with perl
XML processing with perlXML processing with perl
XML processing with perl
Joe Jiang
 
Linq 090701233237 Phpapp01
Linq 090701233237 Phpapp01Linq 090701233237 Phpapp01
Linq 090701233237 Phpapp01
google
 

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

Lecture 4 - Comm Lab: Web @ ITP
Lecture 4 - Comm Lab: Web @ ITPLecture 4 - Comm Lab: Web @ ITP
Lecture 4 - Comm Lab: Web @ ITP
 
My First Rails Plugin - Usertext
My First Rails Plugin - UsertextMy First Rails Plugin - Usertext
My First Rails Plugin - Usertext
 
Malli: inside data-driven schemas
Malli: inside data-driven schemasMalli: inside data-driven schemas
Malli: inside data-driven schemas
 
The Real Time Web with XMPP
The Real Time Web with XMPPThe Real Time Web with XMPP
The Real Time Web with XMPP
 
C to perl binding
C to perl bindingC to perl binding
C to perl binding
 
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...
And now you have two problems. Ruby regular expressions for fun and profit by...
 
JavaScript and jQuery Fundamentals
JavaScript and jQuery FundamentalsJavaScript and jQuery Fundamentals
JavaScript and jQuery Fundamentals
 
Beginning Scala Svcc 2009
Beginning Scala Svcc 2009Beginning Scala Svcc 2009
Beginning Scala Svcc 2009
 
C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0
 
iRODS Rule Language Cheat Sheet
iRODS Rule Language Cheat SheetiRODS Rule Language Cheat Sheet
iRODS Rule Language Cheat Sheet
 
Os Fetterupdated
Os FetterupdatedOs Fetterupdated
Os Fetterupdated
 
What you forgot from your Computer Science Degree
What you forgot from your Computer Science DegreeWhat you forgot from your Computer Science Degree
What you forgot from your Computer Science Degree
 
Scala + WattzOn, sitting in a tree....
Scala + WattzOn, sitting in a tree....Scala + WattzOn, sitting in a tree....
Scala + WattzOn, sitting in a tree....
 
Odp
OdpOdp
Odp
 
Scala 2 + 2 > 4
Scala 2 + 2 > 4Scala 2 + 2 > 4
Scala 2 + 2 > 4
 
XML processing with perl
XML processing with perlXML processing with perl
XML processing with perl
 
Linq 090701233237 Phpapp01
Linq 090701233237 Phpapp01Linq 090701233237 Phpapp01
Linq 090701233237 Phpapp01
 
Zend framework 05 - ajax, json and j query
Zend framework 05 - ajax, json and j queryZend framework 05 - ajax, json and j query
Zend framework 05 - ajax, json and j query
 
The bones of a nice Python script
The bones of a nice Python scriptThe bones of a nice Python script
The bones of a nice Python script
 
SQL -PHP Tutorial
SQL -PHP TutorialSQL -PHP Tutorial
SQL -PHP Tutorial
 

Más de Alberto Simões

Más de Alberto Simões (20)

Source Code Quality
Source Code QualitySource Code Quality
Source Code Quality
 
Language Identification: A neural network approach
Language Identification: A neural network approachLanguage Identification: A neural network approach
Language Identification: A neural network approach
 
Google Maps JS API
Google Maps JS APIGoogle Maps JS API
Google Maps JS API
 
Making the most of a 100-year-old dictionary
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
 
Dictionary Alignment by Rewrite-based Entry Translation
Dictionary Alignment by Rewrite-based Entry TranslationDictionary Alignment by Rewrite-based Entry Translation
Dictionary Alignment by Rewrite-based Entry Translation
 
EMLex-A5: Specialized Dictionaries
EMLex-A5: Specialized DictionariesEMLex-A5: Specialized Dictionaries
EMLex-A5: Specialized Dictionaries
 
Modelação de Dados
Modelação de DadosModelação de Dados
Modelação de Dados
 
Aula 04 - Introdução aos Diagramas de Sequência
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
 
Aula 03 - Introdução aos Diagramas de Atividade
Aula 03 - Introdução aos Diagramas de AtividadeAula 03 - Introdução aos Diagramas de Atividade
Aula 03 - Introdução aos Diagramas de Atividade
 
Aula 02 - Engenharia de Requisitos
Aula 02 - Engenharia de RequisitosAula 02 - Engenharia de Requisitos
Aula 02 - Engenharia de Requisitos
 
Aula 01 - Planeamento de Sistemas de Informação
Aula 01 - Planeamento de Sistemas de InformaçãoAula 01 - Planeamento de Sistemas de Informação
Aula 01 - Planeamento de Sistemas de Informação
 
Building C and C++ libraries with Perl
Building C and C++ libraries with PerlBuilding C and C++ libraries with Perl
Building C and C++ libraries with Perl
 
PLN em Perl
PLN em PerlPLN em Perl
PLN em Perl
 
Classification Systems
Classification SystemsClassification Systems
Classification Systems
 
Redes de Pert
Redes de PertRedes de Pert
Redes de Pert
 
Dancing Tutorial
Dancing TutorialDancing Tutorial
Dancing Tutorial
 
Processing XML: a rewriting system approach
Processing XML: a rewriting system approachProcessing XML: a rewriting system approach
Processing XML: a rewriting system approach
 
Sistemas de Numeração
Sistemas de NumeraçãoSistemas de Numeração
Sistemas de Numeração
 
Álgebra de Boole
Álgebra de BooleÁlgebra de Boole
Álgebra de Boole
 
Arquitecturas de Tradução Automática
Arquitecturas de Tradução AutomáticaArquitecturas de Tradução Automática
Arquitecturas de Tradução Automática
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Último (20)

Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

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