The following is a snippet from my code to allow for testing to get the actual logic to work. I have used a similar functionality in a CSV format and it worked but when I try to use it in a XML format it won't save to a XML file, even when I "export" it.

Installed Perl modules to support the functionality:
* DBI
* SQL::Statement
* DBD::File
* AnyData
* DBD::AnyData
* XML::Twig
* XML::Parse

I've left in the comments where the error occurs and what the error messages shows. Also shows all the "attempts" (should say "failures") in the comments below.

Thanks for any help or suggestions,
warsting

use DBI; $name = 'Testing'; $agency = 'TT'; $email = 'test@abc.com'; $org = 'ABC'; $mailstop = 'X159'; $phone = '(555) 123-4567'; $title = 'Other'; $DATA_COLUMNS = 'name,agency,email,org,mailstop,phone,title'; # tried it with/without the 'eadata' tag too (ie '/eadata/user/name' f +or the first one) $XML_COL_MAP = [ {'/eadata/user/name','name'}, {'/eadata/user/agency','agency'}, {'/eadata/user/email','email'}, {'/eadata/user/org','org'}, {'/eadata/user/mailstop','mailstop'}, {'/eadata/user/phone','phone'}, {'/eadata/user/title','title'} ]; # open a new connection to the XML file (user.xml) $dbh = DBI->connect('dbi:AnyData(RaiseError=>1):'); #$dbh->func('users', 'XML', './users.xml', {col_names => $DATA_COLUMNS +, col_map => $XML_COL_MAP}, 'ad_import'); # XML file added below for ease of testing $dbh->func('users', 'XML', [<DATA>], {col_names => $DATA_COLUMNS, col_ +map => $XML_COL_MAP}, 'ad_import'); #$dbh->func('users', 'XML', [<DATA>], {col_names => $DATA_COLUMNS}, 'a +d_import'); # insert a new record in to the memory table 'users' $SQL = qq{insert into users($DATA_COLUMNS) values('$name','$agency','$email','$org','$mailstop','$phone +','$title')}; $dbh->do($SQL); # export out to a new file (users_new.xml) $dbh->func('users', 'XML', './users_new.xml', {col_names => $DATA_COLU +MNS, col_map => $XML_COL_MAP}, 'ad_export'); #$dbh->func('users', 'XML', './users_new.xml', {col_names => $DATA_COL +UMNS}, 'ad_export'); # getting this error (no matter which line above I try)): # SQL ERROR: Bad table or column name '1' starts with non-alphabetic + character! # -- actually errors twice # close the database and closes the file $dbh->disconnect; # this is from the xml file (users.xml), places here for ease of testi +ng __END__ <eadata> <user> <name>Testing Tester</name> <agency>LL</agency> <email>test4@abc.net</email> <org>Test</org> <mailstop>T125</mailstop> <phone>98765</phone> <title>Other</title> </user> <user> <name>Walt Arsting...</name> <agency>XX</agency> <email>arsting...@xyz.net</email> <org>ASQ</org> <mailstop>L339</mailstop> <phone>555-123-4567</phone> <title></title> </user> </eadata>

In reply to Saving data to XML file using DBD::AnyData by warsting

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.