f



How to convert csv file to XML using XML::Simple?

I need to take a comma separated value (csv) file and convert it to XML.
I'm trying to do this with XML::Writer.  Using XML::Writer I can see how
to convert FROM an XML document, but I don't see how to take a csv file
and convert it to XML.  If I had a csv file like this:

Robert, Smith, 123 Main St.
Jane, Smith, 456 Market St.
William, Watson, 789 First Ave.


How would I convert that to an XML file like this:

<?xml version="1.0" ?>
<ADDRESSBOOK>
  <CONTACT>
    <FIRST_NAME> Robert  </FIRST_NAME>
    <LAST_NAME> Smith </LAST_NAME>
    <ADDRESS> 123 Main St. </ADDRESS>
  </CONTACT>
  <CONTACT>
    <FIRST_NAME> Jane  </FIRST_NAME>
    <LAST_NAME> Smith </LAST_NAME>
    <ADDRESS> 456 Market St. </ADDRESS>
  </CONTACT>
  <CONTACT>
    <FIRST_NAME> William  </FIRST_NAME>
    <LAST_NAME> Watson </LAST_NAME>
    <ADDRESS> 789 First Ave. </ADDRESS>
  </CONTACT>
</ADDRESSBOOK>


Any help would be greatly appreciated!

0
jegan472 (20)
11/2/2007 2:54:09 AM
comp.lang.perl.misc 33233 articles. 2 followers. brian (1246) is leader. Post Follow

8 Replies
887 Views

Similar Articles

[PageSpeed] 16

That should read all refer to XML::Simple, not XML::Writer.


0
James
11/2/2007 3:02:35 AM
On Nov 1, 10:54 pm, James Egan <jegan...@comcast.net> wrote:
> I need to take a comma separated value (csv) file and convert it to XML.
> I'm trying to do this with XML::Writer.  Using XML::Writer I can see how
> to convert FROM an XML document, but I don't see how to take a csv file
> and convert it to XML.  If I had a csv file like this:
>
> Robert, Smith, 123 Main St.
> Jane, Smith, 456 Market St.
> William, Watson, 789 First Ave.
>
> How would I convert that to an XML file like this:
>
> <?xml version="1.0" ?>
> <ADDRESSBOOK>
>   <CONTACT>
>     <FIRST_NAME> Robert  </FIRST_NAME>
>     <LAST_NAME> Smith </LAST_NAME>
>     <ADDRESS> 123 Main St. </ADDRESS>
>   </CONTACT>
>   <CONTACT>
>     <FIRST_NAME> Jane  </FIRST_NAME>
>     <LAST_NAME> Smith </LAST_NAME>
>     <ADDRESS> 456 Market St. </ADDRESS>
>   </CONTACT>
>   <CONTACT>
>     <FIRST_NAME> William  </FIRST_NAME>
>     <LAST_NAME> Watson </LAST_NAME>
>     <ADDRESS> 789 First Ave. </ADDRESS>
>   </CONTACT>
> </ADDRESSBOOK>
>
> Any help would be greatly appreciated!

What have you tried so far?  How did it not work the way you wanted?

I would use Text::CSV to parse the CSV, and create a hash out of each
line, then pass the resulting data structure to XMLout(), like so:

#!/usr/bin/perl
use strict;
use warnings;
use Text::CSV;
use XML::Simple;

my @col_names = qw/FIRST_NAME LAST_NAME ADDRESS/;
my $csv = Text::CSV->new();
my $xml = { CONTACT => [ ] };
while (<DATA>) {
   chomp;
   $csv->parse($_);
   my @cols = $csv->fields();
   my %hash = map { $col_names[$_] => $cols[$_] } 0..$#cols;
   push @{$xml->{CONTACT}}, \%hash;
}
print XMLout($xml,  RootName => "ADDRESS_BOOK", NoAttr => 1);
__DATA__
Robert, Smith, 123 Main St.
Jane, Smith, 456 Market St.
William, Watson, 789 First Ave


Paul Lalli

0
Paul
11/2/2007 10:55:11 AM
James Egan <jegan472@comcast.net> wrote:

> Robert, Smith, 123 Main St.
> Jane, Smith, 456 Market St.
> William, Watson, 789 First Ave.
>
>
> How would I convert that to an XML file like this:
>
><?xml version="1.0" ?>
><ADDRESSBOOK>
>  <CONTACT>
>     <FIRST_NAME> Robert  </FIRST_NAME>
>     <LAST_NAME> Smith </LAST_NAME>
>     <ADDRESS> 123 Main St. </ADDRESS>
>  </CONTACT>
>  <CONTACT>
>     <FIRST_NAME> Jane  </FIRST_NAME>
>     <LAST_NAME> Smith </LAST_NAME>
>     <ADDRESS> 456 Market St. </ADDRESS>
>  </CONTACT>
>  <CONTACT>
>     <FIRST_NAME> William  </FIRST_NAME>
>     <LAST_NAME> Watson </LAST_NAME>
>     <ADDRESS> 789 First Ave. </ADDRESS>
>  </CONTACT>
></ADDRESSBOOK>


--------------------------
#!/usr/bin/perl
use warnings;
use strict;

while ( <DATA> ) {
    chomp;
    my($first, $last, $adr) = split /,\s*/;
    print <<ENDCONTACT;
  <CONTACT>
    <FIRST_NAME>$first</<FIRST_NAME>
    <LAST_NAME>$last</LAST_NAME>
    <ADDRESS>$adr</ADDRESS>
  </CONTACT>
ENDCONTACT
};


__DATA__
Robert, Smith, 123 Main St.
Jane, Smith, 456 Market St.
William, Watson, 789 First Ave.
--------------------------


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
0
Tad
11/2/2007 11:42:10 AM
On Fri, 02 Nov 2007 11:42:10 +0000, Tad McClellan wrote:

> while ( <DATA> ) {
>     chomp;
>     my($first, $last, $adr) = split /,\s*/;
>     print <<ENDCONTACT;
>   <CONTACT>
>     <FIRST_NAME>$first</<FIRST_NAME>
>     <LAST_NAME>$last</LAST_NAME>
>     <ADDRESS>$adr</ADDRESS>
>   </CONTACT>
> ENDCONTACT
> };
> 
> 
> __DATA__
> Robert, Smith, 123 Main St.
> Jane, Smith, 456 Market St.
> William, Watson, 789 First Ave.
> --------------------------


Thanks.  I found a really great module named XML::Generator.  Most modules
like XML::Writer and XML::Simple use a .xml file for input, and then
output XML.
0
James
11/3/2007 1:57:25 PM
On Fri, 02 Nov 2007 03:55:11 -0700, Paul Lalli wrote:
> print XMLout($xml,  RootName => "ADDRESS_BOOK", NoAttr => 1);
> __DATA__
> Robert, Smith, 123 Main St.
> Jane, Smith, 456 Market St.
> William, Watson, 789 First Ave
> 
> 
> Paul Lalli



Thanks.  I found a really great module named XML::Generator.  Most modules
like XML::Writer and XML::Simple use a .xml file for input, and then
output XML.
0
James
11/3/2007 1:58:07 PM
On Nov 3, 9:58 am, James Egan <jegan...@comcast.net> wrote:
> On Fri, 02 Nov 2007 03:55:11 -0700, Paul Lalli wrote:
> > print XMLout($xml,  RootName => "ADDRESS_BOOK", NoAttr => 1);
> > __DATA__
> > Robert, Smith, 123 Main St.
> > Jane, Smith, 456 Market St.
> > William, Watson, 789 First Ave
>
> > Paul Lalli
>
> Thanks.  I found a really great module named XML::Generator.
> Most modules like XML::Writer and XML::Simple use a .xml file for
> input, and then output XML.

You're making no sense.  XML::Simple, as I demonstrated above, does
not take *any* file for input.  It takes a reference to a hash
structure, and then outputs XML.

Why are you bothering to thank me when you obviously didn't read my
post?

Paul Lalli

0
Paul
11/3/2007 2:58:20 PM
On Sat, 03 Nov 2007 07:58:20 -0700, Paul Lalli <mritty@gmail.com> wrote:

>On Nov 3, 9:58 am, James Egan <jegan...@comcast.net> wrote:
>> On Fri, 02 Nov 2007 03:55:11 -0700, Paul Lalli wrote:
>> > print XMLout($xml,  RootName => "ADDRESS_BOOK", NoAttr => 1);
>> > __DATA__
>> > Robert, Smith, 123 Main St.
>> > Jane, Smith, 456 Market St.
>> > William, Watson, 789 First Ave
>>
>> > Paul Lalli
>>
>> Thanks.  I found a really great module named XML::Generator.
>> Most modules like XML::Writer and XML::Simple use a .xml file for
>> input, and then output XML.
>
>You're making no sense.  XML::Simple, as I demonstrated above, does
>not take *any* file for input.  It takes a reference to a hash
>structure, and then outputs XML.
>
>Why are you bothering to thank me when you obviously didn't read my
>post?
>
>Paul Lalli
Why would anybody want to thank you? You know absolutely nothing
about XML



0
sln
11/12/2007 3:11:49 AM
On Fri, 02 Nov 2007 11:42:10 GMT, Tad McClellan <tadmc@seesig.invalid> wrote:

>James Egan <jegan472@comcast.net> wrote:
>
>> Robert, Smith, 123 Main St.
>> Jane, Smith, 456 Market St.
>> William, Watson, 789 First Ave.
>>
>>
>> How would I convert that to an XML file like this:
>>
>><?xml version="1.0" ?>
>><ADDRESSBOOK>
>>  <CONTACT>
>>     <FIRST_NAME> Robert  </FIRST_NAME>
>>     <LAST_NAME> Smith </LAST_NAME>
>>     <ADDRESS> 123 Main St. </ADDRESS>
>>  </CONTACT>
>>  <CONTACT>
>>     <FIRST_NAME> Jane  </FIRST_NAME>
>>     <LAST_NAME> Smith </LAST_NAME>
>>     <ADDRESS> 456 Market St. </ADDRESS>
>>  </CONTACT>
>>  <CONTACT>
>>     <FIRST_NAME> William  </FIRST_NAME>
>>     <LAST_NAME> Watson </LAST_NAME>
>>     <ADDRESS> 789 First Ave. </ADDRESS>
>>  </CONTACT>
>></ADDRESSBOOK>
>
>
>--------------------------
>#!/usr/bin/perl
>use warnings;
>use strict;
>
>while ( <DATA> ) {
>    chomp;
>    my($first, $last, $adr) = split /,\s*/;
>    print <<ENDCONTACT;
>  <CONTACT>
>    <FIRST_NAME>$first</<FIRST_NAME>
>    <LAST_NAME>$last</LAST_NAME>
>    <ADDRESS>$adr</ADDRESS>
>  </CONTACT>
>ENDCONTACT
>};
>
>
>__DATA__
>Robert, Smith, 123 Main St.
>Jane, Smith, 456 Market St.
>William, Watson, 789 First Ave.
>--------------------------
You can't write xml this way can you????
No, I didn't think so.
0
sln
11/12/2007 3:13:43 AM
Reply:

Similar Artilces:

Different results parsing a XML file with XML::Simple (XML::Sax vs. XML::Parser)
Hello Usenet. I'm subject to some confusion with XML and UTF8. I'm working with XML-Simple and I try to decode some XML with with german umlauts (ISO-8859-1). The first XML line declared the encoding correct (see code below). But I'm getting different results using XML-Simple with the default XML parser named XML::Sax and a second parser named XML::Parser. The following code tries to decode the mini XML file and prints the UTF8 flags of the resulting strings. Can someone run this code on his machine and post the results? Thanks. The results on my machine are this: ���ä...

How to Split a XML file to multiple small XML Files using VB.net
Hello, I am trying to split a XML file to multiple small xml files in vb.net and am trying to get the best possible approach to this. Any help on this will be great... Sample example on what I am trying to do... Source XML document -------------------------- <?xml version="1.0" standalone="yes"?> <SynchronizationObjectsDocument > <ApplicationArea> <DocId>dea9593b-4c60-4c1a-ab7f-004a4e336ac5</DocId> <CreationDateTime>2004-05-13T21:31:48-04:00</CreationDateTime> </ApplicationArea> <Data> <V_CLI_...

Question about printing XML using XML::Simple
I'm using XML::Simple to read an XML file named test.xml, which is listed below. I'm trying to print individual elements in the xml file like this: my $xml = new XML::Simple(KeyAttr=>[], ForceArray => 1); my $ref = $xml->XMLin($xmlfile); ##print Dumper($ref); #These don't work print $ref->{USER}->{NAME}->{FIRST_NAME}; print $ref->{XMLFILE}->{USER}->{NAME}->{FIRST_NAME}; print $ref->{USER}->{NAME}->{FIRST_NAME}->[0]; How can I print an individual element like <LAST_NAME>? -Thanks test.xml: <XMLFILE> <USER> <NAME> <FIRST_NAME> FRED </FIRST_NAME> <LAST_NAME> FLINTSTONE </LAST_NAME> </NAME> <ADDRESS> <ADD_LINE1> 123 Main Street </ADD_LINE1> <CITY> Bedrock </CITY> <STATE> CA </STATE> <ZIP> 23912 </ZIP> </ADDRESS> </USER> </XMLFILE> This should work. You were on the right track for your syntax for the references in the converted hash. The problem might have been with the call to XMLin. stratfan ================================= #!/usr/bin/perl use XML::Simple; my $testxml = <<"EOF"; <XMLFILE> <USER> <NAME> <FIRST_NAME> FRED </FIRST_NAME> <LAST_NAME> FLINTSTONE </LAST_NAME> </NAME> <ADDRESS> <ADD_LINE1> 123 Main Street </ADD_LINE1> <CITY> Bedrock...

Error when using XML::Simple with XML::LibXML
I've successfully installed XML::Simple and XML::LibXML. the following code gives me an error: ---- #!/usr/local/bin/perl .... use XML::Simple; $XML::Simple::PREFERRED_PARSER = 'XML::LibXML'; my $xs1 = XML::Simple->new(); my $doc = $xs1->XMLin($input, forcearray=>1); ---- The error is: Can't locate object method "xml_decl" via package "XML::Simple" at /home/leif/perl/lib/perl5/site_perl/5.8.0/i386-linux/XML/LibXML.pm line 369. at /home/leif/perl/lib/perl5/site_perl/5.8.0/XML/Simple.pm line 295 What have I done wrong? Leif ...

Perl XML::Simple Accessing complex XML
Hi <companyname count="1"> <property id="55467" md="2008-03-20" mc="GBP" mp="173000" > <psumm><![CDATA[This 3 bedroom, ]]></psumm> <a1>1 Bucket Way</a1> <at>Stafford</at> <ac>Staffordshire</ac> <actry></actry> <images> <image id="543">Property Image</image> <image id="545">Property Image</image> </images> </property> </companyname> I am trying to read the above (simplified) with XML::Simple...

Update XML files using XML query language?
Could I use the XML query language (and with appropriate XML query engine) to update XML files? I am pretty sure about querying, but not about updating. Thanks! Jim Jim Cheng wrote: > Could I use the XML query language (and with appropriate XML query engine) > to update XML files? No, currently you can't use it as a "real" update language with insertions and similar. You can however query the source document, alter it through transformations/queries and write the result to the original file. That is probably not as efficient as updating should be.:-) -- Sebastian PGP Key fingerprint = 13 1D 2E 4F 20 3E C9 1F 4C 57 52 87 8A 80 48 4D F5 E9 97 EC Thanks for your comments. Do you know where I could find more information about altering querying expressions to achieve the updating function? Thank you! Jim "Sebastian Schaffert" <wastl@wastl.net> wrote in message news:bg438m$ui8$2@minotaurus.cip.informatik.uni-muenchen.de... > Jim Cheng wrote: > > > Could I use the XML query language (and with appropriate XML query engine) > > to update XML files? > > No, currently you can't use it as a "real" update language with insertions > and similar. You can however query the source document, alter it through > transformations/queries and write the result to the original file. That is > probably not as efficient as updating should be.:-) > > -- > Sebastian > > PGP Key f...

Validating xml file against xml schema using javascript
Hi All, I am trying to take an xml file as input from user and update the sql database with this new data from the xml file. Before going to the step of updating the data in the database, i want to validate this xml file with the xml schema file that i have, to make sure that the user has indeed provided a correctly formed xml, and that the schema of the xml is correct. Now i have searched for some examples as i am new to working with xml files, all i get is samples for .net (xmlvalidatingreader). Can you please give me samples that can be used in asp (not asp.net please) using javascript to validate an xml file against a given xml schema file. Appreciate your help a lot ...

XML to XML
I have a gnucash file that I'm trying to transform into an identical XML file without the invoices. I've been at this for a while now. The gnucash file is in XML and the element I'm looking into is: <gnc:transaction> I want to ignore those that contain <slot:key>gncInvoice</slot:key> which is a child of slot which is a child of slots which is a child of transactions. Any help you're willing to provide would be greatly appreciated. Thanks. Classic application for XSLT. Start with the identity transformation, then add a template which matches the ones you want to treat specially and yields no output. From your description that would be match="gnc:transaction[transactions/slots/slot/slot:key='gncInvoice']" with the namespaces declared appropriately in the stylesheet. (That looks like a somewhat unlikely markup design to me, but since I haven't played with gnucash at all I'm taking your word for it.) -- () ASCII Ribbon Campaign | Joe Kesselman /\ Stamp out HTML e-mail! | System architexture and kinetic poetry Actually, from the Relax-NG schema for gnucash, it looks like it should be more like "gnc:transaction[trn:slots/slot/slot:key='gncInvoice']" with gnc:, trn:, and slot: all bound to the appropriate namespace URIs. The fact that some of their elements -- eg <slot> -- aren't in any namespace is probably left over from a pre-namespaces initial design, as is their now-brok...

UPnP xml file to WSDL xml file
Hello, could somebody help me to convert the below UPnP service file to WSDL web service file: <serviceList> <service> <serviceType> urn:schemas-upnp-org:service:PowerSwitch:1 </serviceType> <serviceId> urn:upnp-org:service:PowerSwitch:1 </serviceId> <controlURL>/upnp/control/power1</controlURL> <eventSubURL>/upnp/control/power1</eventSubURL> <SCPDURL>/blenderpowerSCPD.xml</SCPDURL> </service> thanks in advance bobby I tried to combine UPnP servive and blenderpowerSCPD.xml and come up with WSDL web service file as below: UPnP services: <serviceList> <service> <serviceType> urn:schemas-upnp-org:service:PowerSwitch:1 </serviceType> <serviceId> urn:upnp-org:service:PowerSwitch:1 </serviceId> <controlURL>/upnp/control/power1</controlURL> <eventSubURL>/upnp/control/power1</eventSubURL> <SCPDURL>/blenderpowerSCPD.xml</SCPDURL> </service> .... SCPD file <actionList> <action> <name>SetSpeed</name> <argumentList> <argument> <name>Speed</name> </argument> </argumentList> </action> ... </actionList> NOW the WSDL is as follows: <?xml version="1.0" encoding="UTF-8"?> <definitions name="Device Control" targetNamespace="http://shemas.UPnP.org/"> <messa...

XML or not XML?
I am developing a simple MySQL database editor, and am looking into creating an PHP/AJAX app as the GUI. A lot of this in new ground, and much more is dusting off things I haven't used in a while. My question though involves whether or nor to employ XML. I did some XML a few years back, but don't typically bother anymore. As I see it XML is great when I need to have an app with a standard data presentation that other developers can easily interface. I.E. like a bank statement that may feed a variety of applications developed by a variety of clients. However, if I am developing an integrated solution that doesn't need that kind of ubiquity it just seems to add a layer of unnecessary complexity without any added benefit. I would like to hear some opinions on the pros and cons of using XML for PHP MySQL apps. On Dec 9, 9:54=A0am, William Gill <nore...@example.com> wrote: > I am developing a simple MySQL database editor, and am looking into > creating an PHP/AJAX app as the GUI. =A0A lot of this in new ground, and > much more is dusting off things I haven't used in a while. =A0My question > though involves whether or nor to employ XML. =A0I did some XML a few > years back, but don't typically bother anymore. =A0As I see it XML is > great when I need to have an app with a standard data presentation that > other developers can easily interface. =A0I.E. like a bank statement that > may feed a variety of applications...

How to create brand new XML file using XML::DOM
Hello, I have been wrestling with this issue for 2 hours now... I need to be able to create a fresh XML file {not parsing an existing XML file}. I believe I can use XML::DOM to do this, but I have not found any reference to how to do it on the internet. Could anyone who has accomplished this simple feat please reply and point me in the correct direction to learn what I am doing wrong... Thank you, Michael Uman Sr. Software Engineer, System Tools Sigma Designs ...

Problem Parsing Huge XML file using XML::Twig
Hi, I am trying to parse a Huge XMLfile using XML::Twig.The part of XML file is as following:- This is a sample code:- ------------------------------------------------------------------------------------------------------------------------- <?xml version='1.0'?> <StoreInfo> <StoreName>AEC</StoreName> <Products> <Product> <ProductID>21CR10.2</ProductID> <ProductInfo name="abc" category="xyz">HUGE</ProductInfo> <SupplierID>AEC</SupplierID> <PurchasePrice>10.99</PurchasePrice> <links> <link>http://www.example.com</link> <link>http://www.example2.com</link> </links> </Product> <Product> <ProductID>21CR11.2</ProductID> <ProductInfo name="abcd" category="xyzd">ARROW</ProductInfo> <SupplierID>AEC</SupplierID> <PurchasePrice>10.49</PurchasePrice> <links> <link>http://www.example.com</link> <link>http://www.example2.com</link> </links> </Product> </Products> </StoreInfo> ------------------------------------------------------------------------------------------------------------------------------------ Here,Product Tag repeating 2000 times in original file. I am able to get the values of ProductID,SupplierID and PurchasePrice using the following code.But,How do a ge...

Remove linebreaks from a XML file using Perl
Hello, Would anyone have a sample Perl script to remove line breaks in a XML file? Thanks, Pav yann.pambou@gmail.com wrote: > Hello, > > Would anyone have a sample Perl script to remove line breaks in a XML > file? > > Thanks, > > Pav Ask Pambouy2/Yanis, he's at the same IP address as you (67.83.32.65). gtoomey yann.pambou@gmail.com wrote: > Hello, > > Would anyone have a sample Perl script to remove line breaks in a XML > file? A simple s/\n//sg; should do the job jue "J�rgen Exner" <jurgenex@hotmail.com> wrote: ...

TCL/PHP/XML problem: I need to convert an XML file into a TCL list
My TCL proc, XML_GET_ALL_ELEMENT_ATTRS, is supposed to convert an XML file into a TCL list as follows: attr1 {val1} attr2 {val2} ... attrN {valN} This is the TCL code that does this: [TCL] set contents [read $fileID [file size ${fileName}.xml]]; close $fileID if {![string equal $switch -body]} { # ONLY DO THIS IF THE XML CONTENTS CONTAIN NO BODY - WILL UPGRADE AT A LATER DATE 11/24/2006 - PHIL global serverName if {![info exists serverName]} { global env source ./cgi_globals.tcl global serverName } if {[string length [info procs {URL_ENCODE}]] == 0} { source ../url_procs.tcl }; # INCLUDE NEW url_procs.tcl URL TCL LIBRARY if {[string length [info procs {IS_LIST}]] == 0} { source {./tcl_string_tools.tcl} }; # INCLUDE THE TCL STRING LIBRARY CONTAINING PROC is_list IF !FOUND # BLOCK TO CREATE THE PHP SCRIPT TO PIPE INTO php.exe regsub -all {'} [XML_CLEANUP_ATTRIBUTE $contents] {\&#034;} phpEscapedContents regsub -all {"} $phpEscapedContents {\&quot;} phpEscapedContents set php {<? } append php [subst { if (@is_file("./functions.inc.php")) [format %c 123] }] append php { require_once("./functions.inc.php"); } append php [subst { echo xml_to_tcl_list("$phpEscapedContents"); }] append php [subst {[format %c 125] }] append php { ?>} set cannotRunPHP [catch {exec "echo '$php' | php" >@stdout 2>&stderr} errorMsg] if {$cannotRunPHP...

including one XML file in another XML file
How can I include one XML file into another XML file (on the client side, in Firefox)? I think XInclude is just what I need, but Firefox doesn't support it: https://bugzilla.mozilla.org/show_bug.cgi?id=201754 It seems I also can use an "external entity reference", but that depends on a DTD and I'm using XML Schema. Is it also possible with a Schema and how can I do it? Here is exactly what I'm trying to do: design.xml: <?xml .....> <root> <design>....</design> <library>....</library> </root> Currently the 'library' element is inside the 'design.xml' file. I want to put the library element into a separate xml file and include it in all my design files. (I have a lot of designs and only a couple of libraries). The design.xml file contains a reference to an XSLT file that visualizes the design. When you open the design.xml file in Firefox a SVG (scalable vector graphics) file is created on the fly and shown to you. I also have an XML Schema file that specifies what all the valid elements in the design.xml file are. Can someone show me an example that accomplishes this? That would be great. thanks, Johan. > How can I include one XML file into another XML file (on the client > side, in Firefox)? I'm kind of new to XML, but let me take a stab at answering this. Depending on what you want the client to do with the document, it seems you might be able to accomplish this at th...

XML to XML using XSL
Hi! My XML File is something like this: <?xml version="1.0" encoding="ISO-8859-1"?> <item_list> <item_list_elements> <code>01600</code> <name>John</name> <text>some text ABC</text> </item_list_elements> <item_list_elements> <code>01600</code> <name>Smith</name> <text>another text</text> </item_list_elements> ... </item_list> I need to change <code> values in this file using XSL and produce same XML structure as output. Conditions are: if <text> contains "ABS" and <code> = 01600 then code = "02600" Output scould be: <?xml version="1.0" encoding="ISO-8859-1"?> <item_list> <item_list_elements> <code>02600</code> <name>John</name> <text>some text ABC</text> </item_list_elements> <item_list_elements> <code>01600</code> <name>Smith</name> <text>another text</text> </item_list_elements> ... </item_list> Thanks for all help. Ado @do wrote: > I need to change <code> values in this file using XSL and produce sa...

Where Do I Find (and How Do I Install) XML/XML Parser in Windows XP With Apache for Use With Perl Scripts?
I need to be able to use my perl scripts that use use XML::RSS; use XML::Parser; I have already installed an Apache server and LWP. I am using Windows XP. What should I install now for the above XML capabilities? And where can I find these XML programs? Thanks a million! Gaizer ...

convert ascii .dat files to .xml using Matlab
Hi, I have a set of ascii files with the extension .dat and I need to convert them into a set of .xml files. Is there anyway to do this with Matlab. Thank you very much. ...

converting XML files to text files
Hello, I have written a tool to convert XML files to an from text files using a COBOL copybook as reference. If you are interested, look at : http://txt2xml-rexx.sourceforge.net/ Comments are welcome. Hope this helps Delaunoy P. ...

Installation of: XML-DOM-1.44, XML-Parser-2.36, XML-RSS-1.47, XML-Simple-2.18
- CPAN Forum Q&A, Installation of; -- XML-Writer-0.606 -- XML-DOM-1.44 -- XML-Simple-2.18 -- XML-RSS-1.47 -- XML-Parser-2.36 As concerns the installation of the four items above, these errors are continously flagged as an intervention to the process; XML-Simple-2.18, flagged: ======================== Checking installed modules... could not find ParseDetails.ini in C: \strawberry\perl\vendor\lib\xml\sax XML::Sax is installed, it will be used by the test suite Could not open 'lib/XML/Simple.pm': No such file or directory at C:/ strawberry/perl/lib/ExtUtils/MM_Unix.pm line 2627. -- XML-RSS-1.47, flagged: ======================== Warning: Prerequisite DateTime 0 not found Warning: Prerequisite DateTime::Format::Mail 0 not found Warning: Prerequisite DateTime::Format::W3CDTF 0 not found Could not open 'lib/xml/RSS.pm':No such file or directory at C:/ strawberry/Perl/lib/ExtUtils/MM_Unix.pm line 2627 -- XML-Parser-2.36, flagged*: ============================ C:\strawberry\perl\bin > Perl C:\strawberry\perl\bin\XML- Parser-2.36\makefile.pl expatlibpath=c:\strawberry\c\lib expathincpath=c:\strawberry\c\include PREFIX=..\lib\XML-Parser-2.36 INSTALLDIRS=Perl Expat must be installed prior to building XML::Parser and I cant find it in the standard library directories. Advised to download from; http://sourceforge.net/projects/expat If 'expat' is installed, but in non-standard directory, then use the following options in order to 'MakeFile.pl'; Ex...

appending a new xml file to another existing xml file
Hei, I am having issue using DOM to appending a new xml file (new.xml) to another existing xml file (old.xml) without deleting the existing items in old.xml. I would like to have the new <items> append at the end of existing items at the old.xml. How can I do that? I am using php5 Thanks! Ofuuzo On Feb 18, 9:30 am, ofuu...@yahoo.no wrote: > Hei, > I am having issue using DOM to appending a new xml file (new.xml) to > another existing xml file (old.xml) without deleting the existing > items in old.xml. I would like to have the new <items> append at the > end of existing items at the old.xml. How can I do that? I am using > php5 > > Thanks! > Ofuuzo Share the code you already have and describe any problems you're having with it. We'll be able to better help you that way. On 18 Feb, 17:32, ZeldorBlat <zeldorb...@gmail.com> wrote: > On Feb 18, 9:30 am, ofuu...@yahoo.no wrote: > > > Hei, > > I am having issue using DOM to appending a new xml file (new.xml) to > > another existing xml file (old.xml) without deleting the existing > > items in old.xml. I would like to have the new <items> append at the > > end of existing items at the old.xml. How can I do that? I am using > > php5 > > > Thanks! > >Ofuuzo > > Share the code you already have and describe any problems you're > having with it. We'll be able to better help you that way. Here co...

Use XML to store configurations and convert to different file formats
I want to use XML to store a document's configurations. And I can convert to different file format by using XSL. For example, convert to HTML, PDF, or RTF. But the contents are all stored in single XML file. Are they any documentation management tools/web site that help people do that? please help. thanks!! Matt wrote: > I want to use XML to store a document's configurations. And I can convert > to different file format by using XSL. For example, convert to HTML, > PDF, or RTF. But the contents are all stored in single XML file. > > Are they any documentation management tools/web site that help people do that? You can use XSLT to convert XML to HTML and to XSL-FO which can then be converted to PDF. The XSLT 1.0 documentation is at http://www.w3.org/TR/xslt you can find XSLT processors at http://saxon.sourceforge.net/ http://xml.apache.org/xalan-j/index.html http://xml.apache.org/xalan-c/index.html and several other places. A free FO formatter is available from http://xml.apache.org/fop/index.html If you use an existing document type for your configuration data there might well be existing solutions/stylesheets to transform to HTML and/or PDF but I don't know a DTD for that, try a search engine. -- Martin Honnen http://JavaScript.FAQTs.com/ ...

embedding xml in xml as non-xml :)
Hi all, I have an application that logs in xml. Assume <xmlLog></xmlLog>. In this element the app logs anything it gets from foreign hosts. Now if the host sends xml data, the structure of the document changes. ie. <xmlLog><somTag></somTag></xmlLog>. This will cause problems with my log reader, because it assumes that <xmlLog/> contains non-xml data. My question is, is there a way to treat the data in the <xmlLog/> element as non xml data. Something I can do that would treat anything this element contains as a literal? Any help or suggestions would be greatly appreciated. Regards, Mark Mark Van Orman <mark@icsaccess.com> wrote: > Hi all, > > I have an application that logs in xml. > > Assume <xmlLog></xmlLog>. In this element the app logs > anything it gets from foreign hosts. Now if the host sends xml > data, the structure of the document changes. ie. > <xmlLog><somTag></somTag></xmlLog>. This will cause problems > with my log reader, because it assumes that <xmlLog/> contains > non-xml data. > > My question is, is there a way to treat the data in the > <xmlLog/> element as non xml data. Something I can do that > would treat anything this element contains as a literal? > > Any help or suggestions would be greatly ap...

A good textbook for xml file processing using perl (or Java, PHP, ...)?
Hello, I am looking for a good textbook that covers techniques of processing files in different forms (flat, tagged, indexed, xml, ...) which also has some coverage on database processing. Any recommendation? Thanks, cho I can't recommend a _textbook_, but there's a lot of good info on the web. My standard -- and admittedly biased -- recommendation is to start with the tutorials and articles at the XML DeveloperWorks website (http://www.ibm.com/xml). (Despite being run by IBM, the editors of that site try to treat it as an independently published magazine, so not everything there follows IBM's party line. But it's a good collection.) Thanks for the info. I'll take a look. But it would be nicer if I have a binded book that I can use as a course textbook. Joe Kesselman wrote: > I can't recommend a _textbook_, but there's a lot of good info on the > web. My standard -- and admittedly biased -- recommendation is to start > with the tutorials and articles at the XML DeveloperWorks website > (http://www.ibm.com/xml). > > (Despite being run by IBM, the editors of that site try to treat it as > an independently published magazine, so not everything there follows > IBM's party line. But it's a good collection.) >>>>> ilh.cho@gmail.com (ic) wrote: >ic> Thanks for the info. >ic> I'll take a look. >ic> But it would be nicer if I have a binded book that I can use as a >ic>...

Web resources about - How to convert csv file to XML using XML::Simple? - comp.lang.perl.misc

Resources last updated: 3/29/2016 7:41:08 AM