FWIW, if this is valid XML, this is a perfect application for XSLT.
Using XSLT you can convert it right into .xls (well, into csv, which
can be imported into Excel) and if you're on a Mac (and I assume you
are since you're writing to a mac-only application list) then you
already have xsltproc installed.
The xslt for what you want (if I've understood you correctly) would be
this:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version='1.0' xmlns:xsl="http://www.w3.org/1999/XSL/Transform
">
<xsl:output method="text" version="1.0" encoding="utf-8"
indent="yes" />
<xsl:template match="clipitem">
<xsl:text disable-output-escaping="yes">"</xsl:text>
<xsl:value-of select="name" disable-output-escaping="yes" />
<xsl:text disable-output-escaping="yes">",</xsl:text>
<xsl:text disable-output-escaping="yes">"</xsl:text>
<xsl:value-of select="in" disable-output-escaping="yes" />
<xsl:text disable-output-escaping="yes">",</xsl:text>
<xsl:text disable-output-escaping="yes">"</xsl:text>
<xsl:value-of select="out" disable-output-escaping="yes" />
<xsl:text disable-output-escaping="yes">",</xsl:text>
<xsl:text disable-output-escaping="yes">"</xsl:text>
<xsl:value-of select="start" disable-output-escaping="yes" />
<xsl:text disable-output-escaping="yes">",</xsl:text>
<xsl:text disable-output-escaping="yes">"</xsl:text>
<xsl:value-of select="end" disable-output-escaping="yes" />
<xsl:text disable-output-escaping="yes">"
</xsl:text>
</xsl:template>
<xsl:template match="/ | node() | @* | comment() | processing-
instruction()">
<xsl:apply-templates select="@* | node()"/>
</xsl:template>
</xsl:stylesheet>
Save this to a file called clipitem_stylesheet.xsl
And you make the conversion from the command line as such:
xsltproc /path/to/clipitem_stylesheet.xsl /path/to/clipitem.xml >
clipitem.csv
HTH,
Ted Stresen-Reuter
NB: If any of the fields contain double-quotes, you'll need to do some
special processing or you'll end up with invalid csv.
On Feb 21, 2010, at 3:44 PM, Kim Mosley wrote:
I'm looking for a grep pattern.
Given the below code, I'd like to have reduce it to Slug,0,58,0,58
which I will convert to .xls. So I want only the data from 5 fields
(name, in, out, start, end), and I want to eliminate the field names
and the other fields. If someone could send the pattern to my email:
[email protected] it would be greatly appreciated.
Thanks,
Kim
<clipitem id="Slug">
<name>Slug</name>
<duration>3901</duration>
<rate>
<ntsc>FALSE</ntsc>
<timebase>30</timebase>
</rate>
<in>0</in>
<out>58</out>
<start>0</start>
<end>58</end>
<pixelaspectratio>NTSC-601</pixelaspectratio>
<enabled>TRUE</enabled>
<alphatype>none</alphatype>
<file id="Slug1">
<mediaSource>Slug</mediaSource>
<rate>
<timebase>30</timebase>
</rate>
<duration>3600</duration>
<media>
<video>
<duration>3600</duration>
<samplecharacteristics>
<width>720</width>
<height>480</height>
</samplecharacteristics>
</video>
<audio>
<samplecharacteristics>
<samplerate>48000</samplerate>
<depth>32</depth>
</samplecharacteristics>
<channelcount>2</channelcount>
</audio>
</media>
</file>
<sourcetrack>
<mediatype>video</mediatype>
</sourcetrack>
<fielddominance>lower</fielddominance>
</clipitem>
--
You received this message because you are subscribed to the
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem,
please email "[email protected]" rather than posting to the group.
--
You received this message because you are subscribed to the
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem,
please email "[email protected]" rather than posting to the group.