Sponsored Content
Full Discussion: Converting XML to CSV
Top Forums Shell Programming and Scripting Converting XML to CSV Post 303038750 by Chubler_XL on Thursday 12th of September 2019 05:50:15 PM
Old 09-12-2019
SDohmen, I don't generally thank people for posting questions.

However you've posted good example data and a clear and concise question with a reasonable attempt at solving it yourself. Also the tool your using is the right one for the job, so many XML parsing questions posted here want to use sed / grep / awk which will usually fail given a different XML layout.

Interesting to note that if you start from the parent level, which would have been my first inclination, you only get the first product under that parent:

Code:
xmlstarlet sel -t -m //searchresults/data -v "concat(';',products/idproduct)" -n purchaseorders.xml
;10307107
;10304708

This User Gave Thanks to Chubler_XL For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Converting csv to xls

Hi, Can anyone tell the option to change the file type in unix. i.e. if a file is in csv(Comma Separating Values) format, it should be changed to xls(ordinary MS-Excel) format. But renaming command is not changing to correct file format. Thanks in advance, Milton. (1 Reply)
Discussion started by: miltony
1 Replies

2. Shell Programming and Scripting

converting text to csv format

I am trying to check each line and based on first two digits, the comma needs to be place. I checked in the earlier post where the text is converted to csv with a tab delimited. Here is the test file that needs to be changed to csv 11 051701 22 051701 330123405170105170112345... (13 Replies)
Discussion started by: gthokala
13 Replies

3. UNIX for Dummies Questions & Answers

Converting HTML to CSV

Hi, I need to convert a relatively large html file (1.5megs) into CSV under Unix. How would I be able to do this? Much thanks. (3 Replies)
Discussion started by: Jexel
3 Replies

4. UNIX for Dummies Questions & Answers

Converting spaces to csv

I'm new to shell scripting and I have a file with positional columns. The rows look like this: 222 3333 44444 55 55 55 55 5555 59999 222 3333 44444 55 55 55 55 5555 59999 Not every row has the same number of spaces between the seven columns. They can range anywhere... (11 Replies)
Discussion started by: jkandel
11 Replies

5. Shell Programming and Scripting

Converting a flat file in XML

Hello Friends, I am new to UNIX shell scripting. Using bash....Could you please help me in converting a flat file into an XML style output file. Flat file: (Input File entries looks like this) John Miller: 617-569-7996:15 Bunting lane, staten Island, NY: 10/21/79: 60600 The... (4 Replies)
Discussion started by: humkhn
4 Replies

6. Shell Programming and Scripting

converting specific XML file to CSV

Hi, i would convert the following XML file : <?xml version="1.0" encoding="UTF-8" ?> <files xmlns="http://www.lotus.com/dxl/console"> <filedata notesversion="6" odsversion="43" logged="yes" backup="no" id="C12577E6:004B0DA3" iid="C12577E6:004B0DA8" link="1" dboptions="0,524288,0,0"> ... (24 Replies)
Discussion started by: Nicol
24 Replies

7. Shell Programming and Scripting

Converting CSV to ascii format

Hej All, I have a file like this which is a comma dilimited: input: 6000318,-263.011520678,-59.05869872409,587.67924868792 6000319,-265.6996842902,-50.24902479999,590.65693082607 6000320,-238.1333898366,-288.801232595,633.75332173496... (5 Replies)
Discussion started by: Johanni
5 Replies

8. Shell Programming and Scripting

Help with converting XML to Flat file

Hi Friends, I want to convert a XML file to flat file. Sample I/p: <?xml version='1.0' encoding='UTF-8' ?> <DataFile xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' contactCount='4999' date='2012-04-14' time='22:00:14' xsi:noNamespaceSchemaLocation='gen .xsd'> <Contact... (3 Replies)
Discussion started by: karumudi7
3 Replies

9. UNIX for Dummies Questions & Answers

Need help converting txt to XML

I have a table as following Archive id Line Author Time Text 1fjj34 3 75jk5l 03:20 this is an evidence regarding ... 1fjj34 4 gjhhtrd 03:21 we have seen those documents before 1fjj34 10 645jmdvvb 04:00 Will you consider such an offer?... (0 Replies)
Discussion started by: A-V
0 Replies

10. Shell Programming and Scripting

Using awk for converting xml to txt

Hi, I have a xml script, I converted it to .txt with values comma seperated using awk function. But I want the output values should be inside double quotes My xml script (Workorders.xml) is shown like below: <?xml version="1.0" encoding="utf-8" ?> <scbm-extract version="3.3">... (8 Replies)
Discussion started by: Viswanatheee55
8 Replies
Font::TTF::XMLparse(3pm)				User Contributed Perl Documentation				  Font::TTF::XMLparse(3pm)

NAME
Font::TTF::XMLparse - provides support for XML parsing. Requires Expat module XML::Parser::Expat SYNOPSIS
use Font::TTF::Font; use Font::TTF::XMLparse; $f = Font::TTF::Font->new; read_xml($f, $ARGV[0]); $f->out($ARGV[1]); DESCRIPTION
This module contains the support routines for parsing XML and generating the Truetype font structures as a result. The module has been separated from the rest of the package in order to reduce the dependency that this would bring, of the whole package on XML::Parser. This way, people without the XML::Parser can still use the rest of the package. The package interacts with another package through the use of a context containing and element 'receiver' which is an object which can possibly receive one of the following messages: XML_start This message is called when an open tag occurs. It is called with the context, tag name and the attributes. The return value has no meaning. XML_end This messages is called when a close tag occurs. It is called with the context, tag name and attributes (held over from when the tag was opened). There are 3 possible return values from such a message: undef This is the default return value indicating that default processing should occur in which either the current element on the tree, or the text of this element should be stored in the parent object. $context This magic value marks that the element should be deleted from the parent. Nothing is stored in the parent. (This rather than '' is used to allow 0 returns.) anything Anything else is taken as the element content to be stored in the parent. In addition, the context hash passed to these messages contains the following keys: xml This is the expat xml object. The context is also available as $context->{'xml'}{' mycontext'}. But that is a long winded way of not saying much! font This is the base object that was passed in for XML parsing. receiver This holds the current receiver of parsing events. It may be set in associated application to adjust which objects should receive messages when. It is also stored in the parsing stack to ensure that where an object changes it during XML_start, that that same object that received XML_start will receive the corresponding XML_end stack This is the parsing stack, used internally to hold the current receiver and attributes for each element open, as a complete hierarchy back to the root element. tree This element contains the storage tree corresponding to the parent of each element in the stack. The default action is to push undef onto this stack during XML_start and then to resolve this, either in the associated application (by changing $context->{'tree'}[-1]) or during XML_end of a child element, by which time we know whether we are dealing with an array or a hash or what. text Character processing is to insert all the characters into the text element of the context for available use later. METHODS
perl v5.10.1 2011-02-25 Font::TTF::XMLparse(3pm)
All times are GMT -4. The time now is 06:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy