Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. xsl not formating xml file correctly into csv file

xsl not formating xml file correctly into csv file

Scheduled Pinned Locked Moved XML / XSL
helpxmlquestionregexannouncement
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CodingLover
    wrote on last edited by
    #1

    Hi all, I want to collect some data(not all) from an xml file and write them into a csv file. I used a xsl file formatting for that. Here is my xml file content. <?xml version="1.0" encoding="ISO-8859-1"?> <MAIN> <CATALOG> <PLANT Tag="no"> <LIGHT>Time may differ</LIGHT> <PRICE>$2.44</PRICE> </PLANT> <PLANT Tag="no"> <LIGHT>Fixed time</LIGHT> <PRICE>$9.37</PRICE> </PLANT> </CATALOG> <CHAT> <SOME>Some Text</SOME> <MORE>More Text</MORE> </CHAT> </MAIN> I want to get data on CATALOG element. So here is my style sheet. <?xml version="1.0"?> <xsl:stylesheet version = "1.0" xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <!--<xsl:strip-space elements = "CATALOG"/>--> <xsl:template match="/MAIN/CATALOG/PLANT"> <!--<xsl:text/><xsl:value-of select="normalize-space(PLANT)"/>"<xsl:text/>--> <xsl:value-of select="normalize-space(LIGHT)"/>";"<xsl:text/> <xsl:value-of select="normalize-space(PRICE)"/>" <xsl:text/> <xsl:text disable-output-escaping = "yes" ></xsl:text> </xsl:template> </xsl:stylesheet> But what happened here is, data on CHAT element also added to the file. I only want data on <LIGHT> and <PRICE> elements. But my style sheet gives data on <SOME> and <MORE> elements. How can I correct this. Please help me too fix this. I'm stuck with this for two days. Thanks

    I appreciate your help all the time... CodingLover :)

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups