I am pretty much using xslt and xpath for the first time so please bear with me.I have the following xml (this is only a small part of it):\[code\]<scriptflow description="" entrynodeid="301033924" leftbranch="809" name="Annual Charge and Banding v1.0" quickcode="" rightbranch="810" scriptflowid="301001711" status="1" templateid="-1">- <scriptnode eventid="-1" name="Annual Charge" nodeid="301033924" templateid="1" templatename="action" text="[bookmark=action]Use Information on right hand screen to advise the customer of their annual charge" url="" xpos="100" ypos="130"> <scriptnodeexit exitid="0" exitname="Info Provided" /> <scriptnodeexit exitid="1" exitname="Does NOT Know Property Band" /> <scriptnodeexit exitid="2" exitname="Customer Referred To Valuation Office" /> <scriptnodeexit exitid="3" exitname="Transfer To Council Tax/Offer DDI" /> </scriptnode> <subprocessnode nodeid="301033925" scriptflowid="101000700" scriptflowname="Anything Else v1.0" xpos="530" ypos="10" /> <subprocessnode nodeid="301033926" scriptflowid="101000733" scriptflowname="Revenue Services - Enquiry Transfer v1.0" xpos="300" ypos="360" /> <eventnode eventid="1474" name="Banding Charge" nodeid="301033927" xpos="346" ypos="50" /> - <scriptnode eventid="-1" name="Search for Banding" nodeid="301033928" templateid="1" templatename="action" text="[bookmark=action]Enter postcode and click on go <BR> <BR> Then enter house name/number and click on go [/bookmark]" url="" xpos="420" ypos="84"> <scriptaction command="http://www.bracknell-forest.gov.uk/counciltaxbandreductions" componentid="10" type="0" /> <scriptnodeexit exitid="0" exitname="Found Banding" /> <scriptnodeexit exitid="1" exitname="Property In Another Borough" /> <scriptnodeexit exitid="2" exitname="Banding NOT Found - Transfer To Revenue Services" /> </scriptnode>- <scriptnode eventid="-1" name="Details" nodeid="301033929" templateid="1" templatename="action" text="[bookmark=action]If customer is not happy with the information given, please refer them to valuation office [/bookmark]" url="" xpos="760" ypos="287"> <scriptaction command="http://www.bracknell-forest.gov.uk/your-council/yc-council-tax/yc-amount-payable.htm" componentid="10" type="0" /> <scriptnodeexit exitid="0" exitname="Customer Happy With Information" /> <scriptnodeexit exitid="1" exitname="Customer Not Happy Offer Valuation Office Details" /> </scriptnode> <eventnode eventid="1474" name="Banding Charge" nodeid="301033930" xpos="1016" ypos="20" /> <subprocessnode nodeid="301033931" scriptflowid="101000700" scriptflowname="Anything Else v1.0" xpos="1120" ypos="20" /> - <scriptnode eventid="-1" name="Valuation" nodeid="301033932" templateid="1" templatename="action" text="[bookmark=action] If their propery banding is showing another authority, give them their details by click on authority name on right hand screen [/bookmark]" url="" xpos="810" ypos="190"> <scriptnodeexit exitid="0" exitname="Continue" /> </scriptnode>- <scriptnode eventid="-1" name="Valuation Details" nodeid="301033933" templateid="1" templatename="action" text="[bookmark=action]Give customer details of the valuation office[/bookmark]" url="" xpos="1080" ypos="270"> <scriptnodeexit exitid="0" exitname="Continue" /> </scriptnode>- <scriptnode eventid="-1" name="In Another Area" nodeid="301033934" templateid="1" templatename="action" text="[bookmark=action]Click on the authority name to find contact details[/bookmark]" url="" xpos="743" ypos="69"> <scriptnodeexit exitid="0" exitname="Continue" /> </scriptnode> <subprocessnode nodeid="301033935" scriptflowid="101000733" scriptflowname="Revenue Services - Enquiry Transfer v1.0" xpos="800" ypos="120" /> <nodelink fromnode="301033924" fromnodeexit="0" tonode="301033927" /> <nodelink fromnode="301033924" fromnodeexit="1" tonode="301033928" /> <nodelink fromnode="301033924" fromnodeexit="2" tonode="301033932" /> <nodelink fromnode="301033924" fromnodeexit="3" tonode="301033926" /> <nodelink fromnode="301033927" fromnodeexit="0" tonode="301033925" /> <nodelink fromnode="301033928" fromnodeexit="0" tonode="301033929" /> <nodelink fromnode="301033928" fromnodeexit="1" tonode="301033934" /> <nodelink fromnode="301033928" fromnodeexit="2" tonode="301033935" /> <nodelink fromnode="301033929" fromnodeexit="0" tonode="301033930" /> <nodelink fromnode="301033929" fromnodeexit="1" tonode="301033933" /> <nodelink fromnode="301033930" fromnodeexit="0" tonode="301033931" /> <nodelink fromnode="301033932" fromnodeexit="0" tonode="301033930" /> <nodelink fromnode="301033933" fromnodeexit="0" tonode="301033930" /> <nodelink fromnode="301033934" fromnodeexit="0" tonode="301033930" /> </scriptflow>\[/code\]I need to create a flow chart diagram from this xml. The thing that links one node to another is at the end of this xml:\[code\] <nodelink fromnode="301033924" fromnodeexit="0" tonode="301033927" /> .... <nodelink fromnode="301033933" fromnodeexit="0" tonode="301033930" /> <nodelink fromnode="301033934" fromnodeexit="0" tonode="301033930" /> </scriptflow>\[/code\]The xslt I have so far is as follows:\[code\]<?xml version="1.0" encoding="utf-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"> <xslutput method="html" /> <xslaram name="logo"></xslaram> <xslaram name="folder"></xslaram><xsl:key name="Keytest" match="scriptnode/scriptnodeexit[@exitid]" use="@exitid"/> <xsl:template match="nodelink"> <xsl:for-each select="."> <xsl:choose> <xsl:when test="(preceding-sibling::scriptnode/@nodeid)mod @fromnode=0"> NodeID:<xsl:value-of select="preceding-sibling::scriptnode/@nodeid"/>, Name:<xsl:value-of select="preceding-sibling::scriptnode/@name"/>, </xsl:when> <xsltherwise> <xsl:text>*no nodeID/name match*</xsl:text> </xsltherwise> </xsl:choose> </xsl:for-each> <xsl:choose> <xsl:when test="(preceding-sibling::scriptnode/scriptnodeexit/@exitid) mod @fromnodeexit=0 and (preceding-sibling::scriptnode/@nodeid) div @fromnode=1 and (preceding-sibling::scriptnode/@nodeid) = @fromnode"> From Node ExitID: <xsl:value-of select="@fromnodeexit"/> From Node ID: <xsl:value-of select="@fromnode"/>, ExitID:<xsl:value-of select="preceding-sibling::scriptnode/scriptnodeexit/@exitid"/>, Exitname:<xsl:value-of select="preceding-sibling::scriptnode/scriptnodeexit/@exitname"/> </xsl:when> </xsl:choose> <xsl:choose> <xsl:when test="(preceding-sibling::scriptnode/scriptnodeexit/@exitid)mod @fromnodeexit=0"> ExitID:<xsl:value-of select="preceding-sibling::scriptnode/scriptnodeexit/@exitid"/>, Exitname:<xsl:value-of select="preceding-sibling::scriptnode/scriptnodeexit/@exitname"/> <img src="http://stackoverflow.com/questions/15679797/{$logo}" /> </xsl:when> <xsltherwise> <xsl:text>*no editID/exitname match*</xsl:text><img src="http://stackoverflow.com/questions/15679797/{$logo}" /> </xsltherwise> </xsl:choose> FromNodeExitID:<xsl:apply-templates select="@fromnodeexit"/>, From Node: <xsl:apply-templates select="@fromnode"/>, To Node: <xsl:apply-templates select="@tonode"/> <img src="http://stackoverflow.com/questions/15679797/{$logo}" /><br /> </xsl:template></xsl:stylesheet>\[/code\]I am trying to create a tree structure to later format to make it into a flow-chart but I am struggling with looping through the the scriptnode/scptnode exit attributes. I can't upload an image of the flowchart required but is my xslt on the right track or completely off?