C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » XML »

Convert xml file in my formet


Posted Date: 18 Sep 2009      Posted By: Somya      Member Level: Bronze     Points: 1   Responses: 1



Hi...
i m using asp.net(C#) and sql server when i convert sql table into xml this disply like this

<?xml version="1.0" standalone="yes"?>
<DocumentElement>
<markers>
<ID>1</ID>
<lat>23.441</lat>
<lng>77.1419</lng>
<label>Point A</label>
<html>Test1</html>
</markers>
<markers>
<ID>2</ID>
<lat>23.322</lat>
<lng>77.2133</lng>
<label>Point B</label>
<html>Test2</html>
</markers>
</DocumentElement>

but i have to display just like below pless help me i m searchin code from morrnning.......
<?xml version="1.0" encoding="utf-8"?>
<markers>
<marker lat="23.441" lng="77.1419" label="Point A" html="Test1"/>
<marker lat="23.322" lng="77.2133" label="Point B" html="Test2"/>
<marker lat="23.466" lng="77.4193" label="Point C" html="Test3"/>
<marker lat="23.505" lng="77.1520" label="Point D" html="Test4"/>


</markers>





Responses

Author: ABitSmart    18 Sep 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

You can use XSLT to transform this XML to a format you need.

Something like this,

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="DocumentElement">
<markers>
<xsl:apply-templates/>
</markers>
</xsl:template>

<xsl:template match="marker">
<marker>
<xsl:for-each select="*">
<xsl:attribute name="{name()}">
<xsl:value-of select="text()"/>
</xsl:attribute>

</xsl:for-each>
</marker>
</xsl:template>
</xsl:stylesheet>


Kind regards,
ABitSmart
DNS Web-master, DNS MVM
My blog
Thoughts.exe



Post Reply
You must Sign In to post a response.
Next : Create xml to provide the working location and the file saving location path
Previous : Export sqlserver2005 to xml
Return to Discussion Forum
Post New Message
Category: XML

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use