XML to CSV specific


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting XML to CSV specific
# 1  
Old 09-18-2010
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  
Old 09-18-2010
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  
Old 09-18-2010
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  
Old 09-18-2010
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  
Old 09-19-2010
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 to Ask a Question

Previous Thread | Next Thread

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

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

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

8. Shell Programming and Scripting

CSV processing to XML

Hi, i am really fresh with shell scripting and programming, i have an issue i am not able to solve to populate data on my server for Cisco IP phones. I have CSV file within the following format: ;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;... (9 Replies)
Discussion started by: angel2008
9 Replies

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

10. Shell Programming and Scripting

Help to convert XML to CSV

Apologies if this has already been covered in this site somewhere, I did try looking but without any success. I am new to the whole XML thing, very late starter, and have a requirement to convert an XML fiule to a CSV fomat. I am crrently working on a Solaris OS. Does anyone have any suggestions,... (2 Replies)
Discussion started by: rossingi_33
2 Replies
Login or Register to Ask a Question