XML to CSV specific


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting XML to CSV specific
# 1  
XML to CSV specific

Hi ,

Please any one to help on ,extract this xml code into csv columns list.

Code:
<SOURCEFIELD BUSINESSNAME ="" DATATYPE ="date" DESCRIPTION ="" FIELDNUMBER ="1" 
FIELDPROPERTY ="0" FIELDTYPE ="ELEMITEM" HIDDEN ="NO" KEYTYPE ="NOT A KEY" LENGTH ="19" 
LEVEL ="0" NAME ="BUSINESS_DATE" NULLABLE ="NULL" OCCURS ="0" OFFSET ="0" PHYSICALLENGTH ="19" 
PHYSICALOFFSET ="0" PICTURETEXT ="" PRECISION ="19" SCALE ="0" USAGE_FLAGS =""/>

Regards,
MR
# 2  
What was the result when you searched our extensive database for answers to your question?

Google Search Results for xml to csv | The UNIX and Linux Forums

Did you find any post useful? If so, which one?

Moderator's Comments:
Mod Comment RULES OF THE UNIX AND LINUX FORUMS: (5) Search the forums database with your keywords before asking.
# 3  
The following XSLT stylesheet will transform your XML into CSV:
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="text" encoding="iso-8859-1"/>

<xsl:strip-space elements="*" />

  <xsl:template match="*">
     <xsl:copy>
        <xsl:for-each select="@*">
           <xsl:if test="position() != last()"> "<xsl:value-of select="normalize-space(.)"/>",</xsl:if>
           <xsl:if test="position() = last()">"<xsl:value-of select="normalize-space(.)"/>"<xsl:text>
</xsl:text>
      </xsl:if>
        </xsl:for-each>
        <xsl:apply-templates />
     </xsl:copy>
  </xsl:template>

</xsl:stylesheet>

Here is the output from the transformation
Code:
 "", "date", "", "1", "0", "ELEMITEM", "NO", "NOT A KEY", "19", "0", "BUSINESS_DATE", "NULL", "0", "0", "19", "0", "", "19", "0",""

# 4  
Hi
Thanks for your reply,How this XSLT stylesheet will transform below XML into CSV:


Code:
<?xml version="1.0" encoding="01"?>
<!DOCTYPE SYSTEM "mart.dtd">
<POWERMART CREATION_DATE="09/19/2009 09:16:24" REPOSITORY_VERSION="9.88">
<REPOSITORY NAME="SEV" VERSION="179" CODEPAGE="Latin1" DATABASETYPE="Oracle">
<FOLDER NAME="xx" GROUP="" OWNER="xx1" SHARED="NOTSHARED" DESCRIPTION="" PERMISSIONS="rwx------" UUID="f2708d6c02d4">
    <SOURCE BUSINESSNAME ="" DATABASETYPE ="Oracle" DBDNAME ="DB2" DESCRIPTION ="" NAME ="TARSAN_NEW_REF_DATA" OBJECTVERSION ="1" OWNERNAME ="DEV" VERSIONNUMBER ="1">
   <SOURCEFIELD BUSINESSNAME ="" DATATYPE ="date" DESCRIPTION ="" FIELDNUMBER ="1" FIELDPROPERTY ="0" FIELDTYPE ="ELEMITEM" HIDDEN ="NO" KEYTYPE ="NOT A KEY" LENGTH ="19" LEVEL ="0" NAME ="BUSINESS_DATE" NULLABLE ="NULL" OCCURS ="0" OFFSET ="0" PHYSICALLENGTH ="19" PHYSICALOFFSET ="0" PICTURETEXT ="" PRECISION ="19" SCALE ="0" USAGE_FLAGS =""/>
    </SOURCE>
</FOLDER>
</REPOSITORY>
</MART>

Regards,
MR
# 5  
You need to modify the provided stylesheet to suit your new XML document to apply the template to "//SOURCEFIELD" instead of "*" (which denotes all elements) if that is still the element you want to convert to CSV.

In addition, your XML document is riddled with errors. There is no such encoding as "01". POWERMART and /MART do not match, etc.
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #608
Difficulty: Easy
Python does not need compilation to binary to run.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Xml to csv (again)

Hello, I have copied .xml code for a single item below. I am trying to extract three items (field indices*b244 (second occurrence), b203, and j151), so the desired output would be: 9780323013543 Manual of Natural Veterinary Medicine: Science and Tradition, 1e 68.95 A parallel solution,... (14 Replies)
Discussion started by: palex
14 Replies

2. Shell Programming and Scripting

Moving XML tag/contents after specific XML tag within same file

Hi Forum. I have an XML file with the following requirement to move the <AdditionalAccountHolders> tag and its content right after the <accountHolderName> tag within the same file but I'm not sure how to accomplish this through a Unix script. Any feedback will be greatly appreciated. ... (19 Replies)
Discussion started by: pchang
19 Replies

3. UNIX and Linux Applications

Xml to csv

Hello, Does anyone know of a way to convert an .xml file (ONIX) to something more workable, like a .csv (or even .xls) file? Ideally something on the command line would be ideal, but not absolutely necessary. I would be dealing with .xml files of 125 MB+. I am using XQuartz in El Capitan. ... (17 Replies)
Discussion started by: palex
17 Replies

4. Shell Programming and Scripting

Overwrite specific column in xml file with the specific column from adjacent line

I have an xml file dumped from rrd file, that I want to "patch" so the xml file doesn't contain any blank hole in the resulting graph of the rrd file. Here is the file. <!-- 2015-10-12 14:00:00 WIB / 1444633200 --> <row><v> 4.0419731265e+07 </v><v> 4.5045912770e+06... (2 Replies)
Discussion started by: rk4k
2 Replies

5. Shell Programming and Scripting

XML to CSV

I want to pharse below Xml Using Shell Scripting . Thanks in Advance <md> <neid> <neun>1523</neun> <nedn>XXX1212</nedn> <nesw>fffff12515</nesw> </neid> <mi> <mts>20141128001500</mts> <gp>550</gp> <mt>pmct1</mt> <mt>pmNo2</mt> <mt>pmNo3S</mt> <mv> <moid>Ma=1,Rn=1,Ul=311C</moid>... (6 Replies)
Discussion started by: pareshkp
6 Replies

6. Shell Programming and Scripting

How to convert xml to csv ?

I am in need of converting billions of XML into csv file to load data to DB, i have found the below code in perl but not sure why it's not working properly. CODE: #!/usr/bin/perl # Script to illustrate how to parse a simple XML file # and pick out all the values for a specific element, in... (1 Reply)
Discussion started by: rspwilliam
1 Replies

7. Shell Programming and Scripting

convert huge .xml file in .csv with specific column.

I have huge xml file in server and i want to convert it to .csv with specific column ... i have search in blog but i didn't get any usefully command. Thanks in advance (1 Reply)
Discussion started by: pareshkp
1 Replies

8. 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

9. Shell Programming and Scripting

XML to csv transformation

Hi, I want to write a perl script. Which should accept the xml file, one xsl file and the loaction. The perl script should process the xml file using the xsl file and puts the out put in specified location. For example: My.perl is perls cript. my.xml is like this <?xml version="1.0"... (2 Replies)
Discussion started by: siba.s.nayak
2 Replies

10. Shell Programming and Scripting

CSV to XML

Iam pretty new to UNIX and would like to convert a CSV to an XML file using AWK scripts. Can anybody suggest a solution? My CSV file looks something like this : Serial No Growth% Annual % Commission % Unemployed % 1 35% 29% 59% 42% 2 61% ... (15 Replies)
Discussion started by: pjanakir
15 Replies

Featured Tech Videos