1XML_TO_DB(1) User Contributed Perl Documentation XML_TO_DB(1)
2
3
4
6 xml_to_db - convert a subset of XML into fsdb
7
9 xml_to_db -k EntityField <source.xml
10
12 Converts a very limited subset of XML into Fsdb format.
13
14 The input is XML-format (not fsdb). The input is parsed as XML, and
15 each entity of type ENTITYFIELD is extracted as a row. ENTITYFIELD can
16 have mutliple components separated by slashes to walk down the XML
17 tree, if necessary.
18
19 The input XML file is assumed to be very simple. All rows are assumed
20 to be sequential in one entity. Any other than the specified
21 ENTITYFIELD are ignored. The schema is assumed to be defined by the
22 first instances of that field.
23
24 The output is two-space-separated fsdb. (Someday more general field
25 separators should be supported.) Fsdb fields are normalized version of
26 the CSV file: spaces are converted to single underscores.
27
29 -e EmptyValue or --empty
30 Specify the value newly created columns get.
31
32 This module also supports the standard fsdb options:
33
34 -d Enable debugging output.
35
36 -i or --input InputSource
37 Read from InputSource, typically a file name, or "-" for standard
38 input, or (if in Perl) a IO::Handle, Fsdb::IO or Fsdb::BoundedQueue
39 objects.
40
41 -o or --output OutputDestination
42 Write to OutputDestination, typically a file name, or "-" for
43 standard output, or (if in Perl) a IO::Handle, Fsdb::IO or
44 Fsdb::BoundedQueue objects.
45
46 --autorun or --noautorun
47 By default, programs process automatically, but Fsdb::Filter
48 objects in Perl do not run until you invoke the run() method. The
49 "--(no)autorun" option controls that behavior within Perl.
50
51 --help
52 Show help.
53
54 --man
55 Show full manual.
56
58 Input:
59 <?xml version='1.0' standalone='yes'?>
60 <gnuPod>
61 <files>
62 <file addtime="3389919728" album="Born to Pick" artist="7th Day Buskers" title="Loch Lamor" />
63 <file addtime="3389919728" album="Born to Pick" artist="7th Day Buskers" title="The Floods" />
64 <file addtime="3389919735" album="Copland Conducts Copland" artist="Aaron Copland" title="Our Town" />
65 </files>
66 <playlist name="new shows" plid="97241" >
67 <regex artist="^(Le Show|This American Life)$" />
68 </playlist>
69 </gnuPod>
70
71 Command:
72 xml_to_db -k files/file <gnupod.xml
73
74 Output:
75 #fsdb -F S addtime album artist title
76 3389919728 Born to Pick 7th Day Buskers Loch Lamor
77 3389919728 Born to Pick 7th Day Buskers The Floods
78 3389919735 Copland Conducts Copland Aaron Copland Our Town
79 # | xml_to_db -k files/file
80
82 Fsdb.
83
85 Copyright (C) 2011-2018 by John Heidemann <johnh@isi.edu>
86
87 This program is distributed under terms of the GNU general public
88 license, version 2. See the file COPYING with the distribution for
89 details.
90
91
92
93perl v5.30.1 2020-01-30 XML_TO_DB(1)