473,412 Members | 5,385 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Reformatting xml

Hello,

I have an xml sample string like this:
<?xml version="1.0" encoding="ISO-8859-1"?><catalog><cd><title>Empire
Burlesque</title><artist>Bob
Dylan</artist><country>USA</country><company>Columbia</company><price>10.90</price><year>1985</year></cd></catalog>

and I need to obtaing a new reformatted version like this for a better
display in a richtextbox control:
<?xml version="1.0" encoding="ISO-8859-1"?>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
</catalog>
How can I do that?
Maybe I can do that with xsl or a c# recoursive procedure but what's
better solution?

Thanks

Jan 3 '07 #1
2 1519
Riccardo wrote:
and I need to obtaing a new reformatted version like this for a better
display in a richtextbox control:
<?xml version="1.0" encoding="ISO-8859-1"?>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
</catalog>
How can I do that?
Maybe I can do that with xsl or a c# recoursive procedure but what's
better solution?
Apply an XSLT stylesheet like this:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

<xsl:output method="xml" indent="yes"/>

<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>

With .NET 1.x you should be using System.Xml.Xsl.XslTransform, with .NET
2 and 3 System.Xml.Xsl.XslCompiledTransform to run an XSLT transformation.


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jan 3 '07 #2
Martin Honnen ha scritto:
Apply an XSLT stylesheet like this:
great, thank you.

Jan 3 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Dave | last post by:
After following Microsofts admonition to reformat my system before doing a final compilation of my app I got many warnings/errors upon compiling an rtf file created in word. I used the Help...
0
by: Draz | last post by:
I have some XML extended language that generates output. Everything works ok. I have created additional xsl templates for reformatting strings, mathematical calculations and reformatting numbers....
7
by: David Jacques | last post by:
I have to reformat a string from the form "SRID=4269;POINT(-90.673 69.4310000006199)" to GeometryFromText('POINT (-141.095 68.5430000006417)',4269) ); I have a function to do this by...
12
by: clintonG | last post by:
VS2005 2.0 Beta 2 noting I've posted (to no avail so far) to the somewhat deadzone at news://microsoft.public.vsnet.ide and am getting ants in my pants for some discussion about this issue. ...
2
by: -DG- | last post by:
No reply on my previous query, so I'll post this again. I've done a bit more research in the interim. I'm trying to find an easy way to port code from the older VS2003 format to the format used...
3
by: Chris Lane | last post by:
Hi, This is super annoying FrontPage like behavior. Does anybody know how I can stop the Visual Studio.NET IDE from reformatting my HTML? Thank You
7
by: Lloyd Sheen | last post by:
I know I have seen a way to stop the terrible reformatting that VS 2003 IDE does. Beyond that is MS going to do a better (could not do a worse) job of auto formatting. Every change I make to...
6
by: Abhishek Srivastava | last post by:
Hello All, I am developing a page which has a complex layout. This layout cannot be made using VS alone, so I have to go into the html view and edit the html myself. The problem is that...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.