Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear Professional, below i have mentioned xml file

HTML
<Quote>
  <Table>
    <OrganisationId>1</OrganisationId>
    <OrganisationName>its</OrganisationName>
    <CustomerId>1</CustomerId>
    <CustomerFirstName>Nixon</CustomerFirstName>
    <CustomerMiddleName />
    <CustomerLastName>A</CustomerLastName>
    <CustomerEmail>N@ITS.COM</CustomerEmail>
    <OrganisationAddress>TEST</OrganisationAddress>
    <City>BANG</City>
    <Country>India</Country>
    <PostalCode>566</PostalCode>
  </Table>
  <Table1>
    <QuoteId>1</QuoteId>
    <CustomerId>1</CustomerId>
    <Currency>GBP</Currency>
    <CustomerType>End-User</CustomerType>
    <EndUserName />
    <QuoteCost>3500.00</QuoteCost>
    <Description>Added Temp</Description>
    <Status>false</Status>
    <TemplateId>1</TemplateId>
  </Table1>
  <Table2>
    <QuoteDtlId>2</QuoteDtlId>
    <Product>MYPC-ADD-5</Product>
    <ProductGroup>MyPC Purchase</ProductGroup>
    <Description>MyPC Licence for 5 Computers</Description>
    <ExtendedDescription>Blah Blah</ExtendedDescription>
    <CostPrice>30.00</CostPrice>
    <SellPrice>300.00</SellPrice>
    <Quantity>1</Quantity>
    <Selected>true</Selected>
    <Maintenance>false</Maintenance>
    <MaintenanceId>0</MaintenanceId>
    <Total>300.00</Total>
    <TaxPolicy>Standard</TaxPolicy>
    <AccountingCode>A030</AccountingCode>
    <QuoteId>1</QuoteId>
  </Table2>
  <Table2>
    <QuoteDtlId>3</QuoteDtlId>
    <Product>MYPC-BASE</Product>
    <ProductGroup>MyPC Purchase</ProductGroup>
    <Description>MyPC Base Licence Includes: Centralised Database. Internet / Intranet Booking. Library Fines and Overdue Items Module. Full Documentation and Reference Guides. Installation and Training (including all expenses). </Description>
    <ExtendedDescription>Blah Blah</ExtendedDescription>
    <CostPrice>320.00</CostPrice>
    <SellPrice>3200.00</SellPrice>
    <Quantity>1</Quantity>
    <Selected>false</Selected>
    <Maintenance>false</Maintenance>
    <MaintenanceId>0</MaintenanceId>
    <Total>3200.00</Total>
    <TaxPolicy>Standard</TaxPolicy>
    <AccountingCode>A030</AccountingCode>
    <QuoteId>1</QuoteId>
  </Table2>
  <Table3>
    <TemplateType>text</TemplateType>
    <TemplateHtml>&lt;p&gt;AAAAAAAA&lt;br data-mce-bogus="1"&gt;&lt;/p&gt;</TemplateHtml>
  </Table3>
  <Table3>
    <TemplateType>text</TemplateType>
    <TemplateHtml>&lt;p&gt;cccccccccccccccc&lt;br data-mce-bogus="1"&gt;&lt;/p&gt;</TemplateHtml>
  </Table3>
  <Table3>
    <TemplateType>pricing</TemplateType>
    <TemplateHtml />
  </Table3>
  <Table3>
    <TemplateType>pageBreak</TemplateType>
    <TemplateHtml />
  </Table3>
  <Table3>
    <TemplateType>text</TemplateType>
    <TemplateHtml>
      XXXXXXXXXXXXXXXXX
    </TemplateHtml>
  </Table3>
</Quote>


My XSl file is:
XML
<xsl:for-each select="Quote/Table3">
   </xsl:for-each>


Inside the for each statement i want to read Table1 values ..

Thanks In advance ..please help me .
Posted
Updated 23-Apr-15 1:25am
v4
Comments
Maciej Los 23-Apr-15 7:26am    
What's the issue? What are you trying to achieve?
We can't read in your mind or direct from your screen...
nirmal nixon 24-Apr-15 1:44am    
Thanks for your reply .

Can you see the XSLT code ?

If means inside the XSL for each i want to read <Table2> </Table2> child element values .
Maciej Los 24-Apr-15 1:52am    
Have you tried to escape from loop via //table2/Field or .../table2/Field?

1 solution

Add reference to xml (see second line):
XML
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<Quote>
  <Table>


Now try this xsl content:
XML
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
  <html>
  <body>
  <h1>Table2</h1>
  <table>
    <tr><th>QuoteDtlId</th><th>CostPrice</th><th>SellPrice</th><th>Total</th><th>Currency</th></tr>
    <xsl:for-each select="Quote/Table2">
    <tr>
    <td><xsl:value-of select="QuoteDtlId" /></td>
    <td><xsl:value-of select="CostPrice" /></td>
    <td><xsl:value-of select="SellPrice" /></td>
    <td><xsl:value-of select="Total" /></td>
    <!-- this element comes from outside a loop-->
    <td><xsl:value-of select="../Table1/Currency" /></td>
    </tr>
    </xsl:for-each>
  </table>
  </body>
  </html>
</xsl:template>

</xsl:stylesheet>



Result of conversion:
HTML
<html>
<body>
<h1>Table2</h1>
<table><tbody>
<tr><th>QuoteDtlId</th><th>CostPrice</th><th>SellPrice</th><th>Total</th><th>Currency</th>
<tr><td>2</td><td>30.00</td><td>300.00</td><td>300.00</td><td>GBP</td></tr>
<tr><td>3</td><td>320.00</td><td>3200.00</td><td>3200.00</td><td>GBP</td></tr>
</tbody>
</table>
</body>
</html>


Change it to your needs ;)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900