Help, with deleteing a element
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 4
- Joined: Wed Feb 04, 2009 2:30 am
Help, with deleteing a element
Hi
I'm a XML newbie, i'm apologizing ahead of time.
I have a several large XML files, some too large for Oxygen to open even.
So i've broken them up in small sets of data.
They are flat exports from a old crm, one of the data fields is old emails, including the body of the html emails. I would like to delete that element out of the XML file. I dont' need that field/data in the field. My File would probaly go from 100mb to 10mb.
Tree
Registrant#
>Name
>Phone
>Subject
>Body (need to delete this in the entire file)
Please help, I will buy you a pint in internet land.
Thanks
I'm a XML newbie, i'm apologizing ahead of time.
I have a several large XML files, some too large for Oxygen to open even.
So i've broken them up in small sets of data.
They are flat exports from a old crm, one of the data fields is old emails, including the body of the html emails. I would like to delete that element out of the XML file. I dont' need that field/data in the field. My File would probaly go from 100mb to 10mb.
Tree
Registrant#
>Name
>Phone
>Subject
>Body (need to delete this in the entire file)
Please help, I will buy you a pint in internet land.
Thanks
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Re: Help, with deleteing a element
You can try an XSLT like below
if you want to remove also the additional line that will remain add also the following template
Note that you can invoke the transformation without opening the XML file in oXygen. You can invoke it from the stylesheet or from the project panel contextual menu, see the "Apply transformation scenario" and "Transform with" actions.
If you still have problems let me know.
Regards,
George
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Body"/>
</xsl:stylesheet>
Code: Select all
<xsl:template match="text()">
<xsl:if test="not(following-sibling::*[1][self::Body])"><xsl:copy-of select="."/></xsl:if>
</xsl:template>
If you still have problems let me know.
Regards,
George
George Cristian Bina
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Re: Help, with deleteing a element
I assume you want to convert the same document to comma separated value. For instance:
will give you on a sample like:
the following CSV:
and if you want to add also the header add
and you will get
Best Regards,
George
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="text"/>
<xsl:template match="Registrant">
<xsl:value-of select="* except Body" separator=","/>
<xsl:text> </xsl:text>
</xsl:template>
<xsl:template match="text()"/>
</xsl:stylesheet>
Code: Select all
<x>
<Registrant>
<Name>name1</Name>
<Phone>phone1</Phone>
<Subject>subject1</Subject>
<Body>body1</Body>
</Registrant>
<Registrant>
<Name>name2</Name>
<Phone>phone2</Phone>
<Subject>subject2</Subject>
<Body>body2</Body>
</Registrant>
</x>
Code: Select all
name1,phone1,subject1
name2,phone2,subject2
Code: Select all
<xsl:template match="/*">
<xsl:value-of select="Registrant[1]/(* except Body)/name()" separator=","/>
<xsl:text> </xsl:text>
<xsl:apply-templates/>
</xsl:template>
Code: Select all
Name,Phone,Subject
name1,phone1,subject1
name2,phone2,subject2
George
George Cristian Bina
Return to “General XML Questions”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service