Transform XML to XML

I've been trying to transform an XML document to another XML document. The original document is very large (6megs) and the application that needs to use it only needs a fraction of the data.

I'm trying to take this mother-of-all XML documents and filter out unwanted nodes.
I could probably do this very easily with code by running a few XPath Queries against the document, and placing the results in a new document...however...I have an interest in learning how to do this with XSL.
In the past, I've done some pretty basic XML to HTML transformation ans that worked out well.
This time I'm trying to transform XML to XML and I'm having one hell of a time getting it to work correctly. For the most part, my output is just a bunch of text.....I'm not getting any kind of nested node structure.
Here is really simple example of my source document:
<menu>
<menuitem>
<itemid>1</itemid>
<itemname>Ham Sandwich</itemname>
<price>5.00</price>
<ingredients>
<ingredient>bread</ingredient>
<ingredient>ham</ingredient>
<ingredient>mustard</ingredient>
</ingredients>
</menuitem>
<menuitem>
<itemid>1</itemid>
<itemname>Tuna Sandwich</itemname>
<price>5.00</price>
<ingredients>
<ingredient>bread</ingredient>
<ingredient>tuna</ingredient>
<ingredient>mayo</ingredient>
</ingredients>
</menuitem>
</menu>
I'm trying to transform the XMl, so I get a nice subset of the data in a new XML document. I want the basic structure, I just want to eliminate all the extra detail. So, I'd like to get something like this:
<menu>
<menuitem>
<itemid>1</itemid>
<itemname>Ham Sandwich</itemname>
<price>5.00</price>
</menuitem>
<menuitem>
<itemid>1</itemid>
<itemname>Tuna Sandwich</itemname>
<price>5.00</price>
</menuitem>
</menu>
What is the proper XSL way of doing this?
Thanks....
0
brandonc
8/5/2004 4:04:22 PM
asp.net.xml-datasource 7181 articles. 0 followers. Follow

2 Replies
1525 Views

Similar Articles

[PageSpeed] 8

Unfortunaly I havent worked much with XML to XML, but here is a nice collection of examples:

XML to XML with XSLT
Sonu Kapoor [MVP]
Feel free to ask me any .NET question | Ajax Data Controls Forum
0
SonuKapoor
8/5/2004 11:43:31 PM
Thanks for pointing these samples out. It was just the help I needed.
0
brandonc
8/7/2004 2:10:21 PM
Reply:

Similar Artilces:

XMl to XML
Hello,   I retrieved an XML from the dataset which retrieves data from the table in the database. I need to present the data  in a different structure. Is XSLT the way or are there any other options. please let me know. Thanks!! Yes XSLT is a good choice to convert xml file to other forms. You can take a look at XSLT Tutorial.Sincerely,Young Fang...

XML in, XML out
Hi All (and a happy holiday to those that will get a break), I am trying to read in an XML file of addresses. I need to remove all the address data from the file where code =~ /^000/ (there are none in the example data below). I need to reproduce that data 'as is', so I need to honour the tag structure, although the order of the tags doesn't need to be honoured. I have been trying to use XML::Simple and I had a go with XML::Smart but I haven't been able to get the results I want. My best effort is below (with XML::Simple). There are a couple of differences ...

XML to XML transform
Hi all, I have an XML file in which I just want to change a couple of values.  So, the end result is a new file with exactly the same XML structure.  I am new to XML and XSLT, so I thought I'd start off with something simple; I created an xsl file that would just copy the source directly across without modifying the values (I can do this later, once I have the first bit figured) - <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:con="http://eviware.com/soapui/config"><xsl:template match="/"...

XML Transform to 1 XML file to another XML File
Hello All  I am a novice programmer. I want to transform 1 xml file to another xml file. I am looking for a example code where user will select source xml file and create another xml file in different file with different fields with some default validation of parsing date and default values.  Can anyone help me or let me know any available source code in C#/ASP.Net?  Ms Disha I am assuming you know xslt, if not, you would have to go look at that.  But if you do, then this document will help you out http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=...

XSLT to transform XML into XML in VB.NET
Hello. I need some help with XSLT. We have an XML coming in and I need to transform this XML to a format that we use using XSLT so that future changes in the incoming file are easy to change in the XSLT rather than changing the VB code.This is the sample input file  <MemberReports xsi:schemaLocation="http://developreports/myreport/v1/report.xsd"> <DateCreated>2006-04-15</DateCreated> <MemberReport> <MemberOrganization>MemberOrganization</ReportingOrganization> <Member> <Name> ...

XML::Parser XML::DOM XML::XSLT
------_=_NextPart_001_01C6E0D0.3E27D77A Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable Hi Craig and fellow VMS Perlers, You last wrote about this Fri 3/16/2001 11:24 AM, not counting your very helpful comments on Eisner/Decuserve more recently. One of my colleagues sent me an email requesting that I make XML::XSLT=20 available on VMS. perl 5.8.6, VMS 7.3-2, DECC 7.1 latest ACRTL (version 3) on Alpha XML::XSLT (version 0.48) depends on XML::Parser (version 2.34). This depends on expat (version 2.0.0). I built expat a...

sort xml in xml
Hi, How I can sort xml file in xml with VB.NetThanks,<?xml version="1.0" encoding="ISO-8859-1" ?>  <Liste>   <Form Famille="Administration" idXhtml="" idOffice="31574" nom="ADM" desc="" />   <Form Famille="Admini" idXhtml="" idOffice="31708" nom="ADM- 54 (2000)" desc="" />   <Form Famille="communication" idXhtml="" idOffice="31709" nom="ADM- 133 (2000)" desc="" />   <Form Famille="Admini" idXhtml="" idOffice="31710" nom="ADM- 9 (2000)" desc="" />   <Form Famille="Admini" idXhtml="" idOffice="31711" no...

How to select Xml as Xml?
If I select Xml nodes like this from sql server; select xmlData.query('//Field[@F = "True"]') as extendedInfo from.... ..how to loop through the items in C#? I can't cast it to a System.Xml.XmlNodeList..? You can use the XmlDocument class.  There's a Load method and a LoadXml method.  One of these should get you what you want, after which you can select nodes as you need.C# <---> VB.Net Translator mm8: If I select Xml nodes like this from sql server; select xmlData.query('//Field[@F = "True"]') as extendedInfo from.... ...

reading data from xml service or xml datasource
Hi, I'm trying to figure out a way to import data (but not export to, I'm just trying to get their news section) from an external db (SqlServer 2000 or 2005) to a gridview and detailsview on my site (resides at a web host). I spoke to the organisation that owns the external db and they are willing to look into several solutions, whitout giving out their db password etc. Not suprisingly, I was reccomended using a web service. However, I believe I need to install stuff in order to enable one, and so, it won't be able for me (I guess), because of my web host's limitations. Instead, I am now t...

Transform XML to XML (DataSet) using XSLT
Hi. I need help to transform a XML-dokument to a NEW XML-dokument or a DataSet using XSLT transformation. How do tranform this? XmlDocument docXml2 = new XmlDocument(); docXml.Load("xmlurl.xml"); XslTransform docXsl = new XslTransform(); docXsl.Load(Server.MapPath("Myxsl.xsl")); **** docXsl.Transform(docXml,null, ?????????); **** ????????? : needs to be at XML-dokument or at Dataset \Torben DocXml2.Load(docXsl.Transform(docXml,null)); Oleg [XML MVP, MCPD]XmlLab.Net | http://blog.tkachenko.com HI I am still getting a error:...

XML datasource from external website XML file
Hi all i need to extract some data into a page on my website, but the xml file is on different web server, not in our bunch, but out in the ether.is it possible to use this file as a datsource directly, or is there some security issue, and i have to grab it and use it locally...??? the file has been put somewhere it can be accessed with a web browseras this file changes on a daily basis, i would also like to automate the daily retrieval, i'm assuming this is something not too simple either. as you would need a service or something to fire up at a specific time each day?! any he...

Transforming XML into XML, creating a temporary file.
I've some XML which is formatted like such:1 <level1 name="category">2 <level2 name="subcategorya">3 <level3 name="item1" att="stuff" />4 </level2>5 <level2 name="subcategoryb">6 <level3 name="item2" att="stuff" />7 </level2>8 </level1>What I would like to do is transform it into something like this: 1 <category>2 <subcategorya>3 <item1 att="stuff" />4 </subc...

Problem loading an xml string containing xml data into XML document
 Hi all,I have a problem loading an xml string containing xml response data returned by other server(spatial server) into XML document some times becoz the returned xml response contains special chars like <, >, ', etc.Is there any way to parse this XML response string before loading into XML document. Hi Bharath, if you can't find a ready made one you can write one yourself. Parse the string that you get for the elements that it would contain and inject the CDATA element between them to allow special character. example if you have a string <childNode>This con...

Problems writing to an XML file
I'm brand new to using XML (in fact this is my first project), so bear with me, I may need a little hand-holding. I'm trying to create a page which simply adds data to an existing xml file. Ultimately it will add the data from a form, but to keep things simple, I've been simply using pre-defined values. Originally I was able to get the script to write the xml exactly as I needed, however it would simply overwrite the existing file every time it was accessed. This is unacceptable, as it will be used to add data to one file, sort of like a mini database. So after much pain and gnashi...

Web resources about - Transform XML to XML - asp.net.xml-datasource

Möbius transform - Wikipedia, the free encyclopedia
Weisstein, Eric W. , " Möbius Transform " from MathWorld . Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc. , a non-profit ...

Amir Arjomand-A Regime Facing a Legitimacy Crisis Will Transform Dialogue Over a Drying Lake Into A Matter ...
Banooye Sabz hat eine Notiz mit dem Titel Amir Arjomand-A Regime Facing a Legitimacy Crisis Will Transform Dialogue Over a Drying Lake Into A ...

➚ Trevor sez, "Friday and Saturday night, design collective The Mission Business transforms Toronto's ...
Trevor sez, "Friday and Saturday night, design collective The Mission Business transforms Toronto's Evergreen Brick Works into an end of the ...

35 Quotes To Transform Yourself Into A Leader
Leadership is a tricky thing. Is it innate or learned? Who needs it the most? What traits define a strong leader?The fact of the matter is that ...

Voicy Helium Voice Changer Recorder - Transform and change your video.s into funny chipmunk effects on ...
Get Voicy Helium Voice Changer Recorder - Transform and change your video.s into funny chipmunk effects on the App Store. See screenshots and ...

Triton church group transforms old warehouse into 'Bethlehem' marketplace
A scene from biblical Bethlehem was created in Triton last week, thanks to a Pentecostal group in Green Bay.

Abandoned Railway Transforms into Romantic Bike Trail
• About China • About CRI Choose A Language Albanian Arabic Bengali Belarusian Bulgarian Burmese Cambodian Croatian Czech Chinese Simplified ...

Envato Video transforms your photos into amazing movies
... or Readdle’s Scanner Pro updated with smart renaming, Box integration and more . Envato Video - Movie Maker & Video Editor Envato Video transforms ...

Intel May Transform from Outside In, Says Linley Group
... editorial this week that there is a giant wave of insiders coming to Intel ( INTC ) for the first time in its history, which could have a transformative ...

8 industries robots will completely transform by 2025
Just as ATMs changed banking and computers took over the home and workplace, robots and artificial intelligence are going to transform a bunch ...

Resources last updated: 12/30/2015 8:40:33 AM