ACEAFTY
asked on
Manipulate large XML file into a small one.
Hi
I have a large XML file from a supplier [over 500mb] but not all the data is relavent to me. So I would like to download the file locally [Windows 7] edit the file by removing all child nodes that I don't need and save to a new XML file by using a software readly available.
It'll be do difficult to go through each node 1 at a time so I would like to search for any subchild nodes that contain "<type_id>17</type_id>" and keep that child node and remove the rest.
Hope this make any sense, any questions please contact me.
Thank you.
I have a large XML file from a supplier [over 500mb] but not all the data is relavent to me. So I would like to download the file locally [Windows 7] edit the file by removing all child nodes that I don't need and save to a new XML file by using a software readly available.
It'll be do difficult to go through each node 1 at a time so I would like to search for any subchild nodes that contain "<type_id>17</type_id>" and keep that child node and remove the rest.
Hope this make any sense, any questions please contact me.
Thank you.
XSLT is the right tool. You can use the free Visual Studio Community Edition to play with it.
Here is another utility which you may find useful:
http://www.microsoft.com/en-us/download/details.aspx?id=21714
http://www.microsoft.com/en-us/download/details.aspx?id=21714
ASKER
Hi
Thanks for the possible solutions. I'm new to XML and I would like to keep the XML file not change it to XSL file or anything else. I need a script that will remove any child nodes that do not contain a particular subchild node value.
e.g.
using the above example I want any <book> elements removed that doesn't contain the author David.
Hope this explains what I'm trying to achieve.
Thanks for the possible solutions. I'm new to XML and I would like to keep the XML file not change it to XSL file or anything else. I need a script that will remove any child nodes that do not contain a particular subchild node value.
e.g.
<books>
<book>
<title>Title 1</title>
<published>2012</published>
<author>David</author>
<isbn>2345234523454</isbn>
</book>
<book>
<title>Title 2</title>
<published>2014</published>
<author>Sam</author>
<isbn>23452345344</isbn>
</book>
<book>
<title>Title 3</title>
<published>2011</published>
<author>Keith</author>
<isbn>566745674</isbn>
</book>
<book>
<title>Title 4</title>
<published>2015</published>
<author>David</author>
<isbn>456745674567</isbn>
</book>
</books>
using the above example I want any <book> elements removed that doesn't contain the author David.
Hope this explains what I'm trying to achieve.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi
I apologise for not responding. My father passed away and have been dealing this the loss. I will check through the comments and respond with my feedback.
I apologise for not responding. My father passed away and have been dealing this the loss. I will check through the comments and respond with my feedback.
ASKER
Hi
I'm new to working with XML and XSLT files. I have no idea were to start and I've read a few tutorial and haven't been able to make much sense of it.
I created the XML file:
and the XSLT file:
I ran the XML file in the browser and nothing happened.
I'm new to working with XML and XSLT files. I have no idea were to start and I've read a few tutorial and haven't been able to make much sense of it.
I created the XML file:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="XSLTFile1.xslt"?>
<books>
<book>
<title>Title 1</title>
<published>2012</published>
<author>David</author>
<isbn>2345234523454</isbn>
</book>
<book>
<title>Title 2</title>
<published>2014</published>
<author>Sam</author>
<isbn>23452345344</isbn>
</book>
<book>
<title>Title 3</title>
<published>2011</published>
<author>Keith</author>
<isbn>566745674</isbn>
</book>
<book>
<title>Title 4</title>
<published>2015</published>
<author>David</author>
<isbn>456745674567</isbn>
</book>
</books>
and the XSLT file:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:output method="XML" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="book[author='David']">
<xsl:element name="book">
<xsl:copy-of select="*" />
</xsl:element>
</xsl:template>
<xsl:template match="book[author!='David']" />
</xsl:stylesheet>
I ran the XML file in the browser and nothing happened.
Use either Visual Studio or msxsl.exe as Paul wrote. The browser as tool makes only sense, when you use XSLT to create HTML as output.
ASKER
I installed Visual Studio and created the 2 files mentioned above.
What I don't know how to do is execute the files so a new XML file is create.
What I don't know how to do is execute the files so a new XML file is create.
ASKER
Yes when I click on XML only option that I have that I can click on is Schemas.... 'Start XSLT Debugging' doesn't appear
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.