Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4606126
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:31:24+00:00 2026-05-22T00:31:24+00:00

i need help in getting the below output from shops.xml file( where incity=yes and

  • 0

i need help in getting the below output from shops.xml file( where incity=”yes” and type=”Botique” ) by using xsl . As i am new to xslt , so any help would be highly appreciated.

shops.xml:

<shops>     
<shop incity="yes" onlineorder="yes">         
<type>Botique</type>         
<address>  
<streetno>23</streetno>
<streetname>collins</streetname>
<suburb>Melbourne</suburb>
</address>     
</shop> 
<shop incity="yes" onlineorder="yes">         
<type>Botique</type>         
<address>  
<streetno>25</streetno>
<streetname>little collins</streetname>
<suburb>Melbourne</suburb>
</address>     
</shop> 
<shop incity="no" onlineorder="yes">         
<type>Tailoring</type>         
<address>  
<streetno>2</streetno>
<streetname>cosmos street</streetname>
<suburb>Glenroy</suburb>
</address>     
</shop>  
</shops>

output:

<shops>     
<shop  onlineorder="yes">         
<type>Botique</type>         
<address>  23 collins,Melbourne </address>     
</shop> 
<shop onlineorder="yes">         
<type>Botique</type>         
<address> 25 little collins, Melbourne </address>     
</shop> 
</shops>

shop.xsl:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">   
<xsl:template match="shop[@incity='no']" />    
<xsl:template match="@* | node()">     
<xsl:copy>    
<xsl:apply-templates select="@* | node()"/>     
</xsl:copy>   
</xsl:template> 
</xsl:stylesheet>

shop.php

<?php
$xmlDoc = new DOMDocument('1.0');
$xmlDoc->formatOutput = true;
$xmlDoc->load("shops.xml");
$xslDoc = new DomDocument;
$xslDoc->load("shop.xsl");
$proc = new XSLTProcessor;
$proc->importStyleSheet($xslDoc);
$strxml= $proc->transformToXML($xmlDoc);
echo ($strxml);
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T00:31:25+00:00Added an answer on May 22, 2026 at 12:31 am

    Here’s something to start with:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
      <xsl:template match="shops">
        <xsl:element name="shops">
          <xsl:for-each select="shop">
            <xsl:if test="@incity='yes'">
              <xsl:if test="type='Botique'">
                <xsl:element name="shop">
                  <xsl:attribute name="onlineorder">
                    <xsl:value-of select="@onlineorder"/>
                  </xsl:attribute>
                  <xsl:element name="type">
                    <xsl:value-of select="type"/>
                  </xsl:element>
                  <xsl:element name="address">
                    <xsl:value-of select="address/streetno"/>
                    <xsl:text> </xsl:text>
                    <xsl:value-of select="address/streetname"/>
                    <xsl:text>, </xsl:text>
                    <xsl:value-of select="address/suburb"/>
                  </xsl:element>
                </xsl:element>
              </xsl:if>
            </xsl:if>
          </xsl:for-each>
        </xsl:element>
      </xsl:template>
    
    </xsl:stylesheet>
    

    Output:

    <?xml version="1.0"?>
    <shops>
      <shop onlineorder="yes">
        <type>Botique</type>
        <address>23 collins, Melbourne</address>
      </shop>
      <shop onlineorder="yes">
        <type>Botique</type>
        <address>25 little collins, Melbourne</address>
      </shop>
    </shops>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a little help getting a tar file to download from a website.
Multi-Test TestNG.xml file results in java.lang.NullPointerException Hello Quality Team, I need help getting TestNG
Using SQL Sever 2005 From the below Query Am getting total worked time means
I need help getting my head around the difference between my current OOP notion
I am getting a little confused and need some help please. Take these two
Using Crystal Report 8.5 Generating a report from table1 My Crystal Report Output ID
I need help on this following aspx code aspx Code: <asp:Label ID =lblName runat
I need help understanding some C++ operator overload statements. The class is declared like
I need help with this route map routes.MapRoute(Blog_Archive, Blog/Archive/{year}/{month}/{day}, new { controller = Blog,
I need help with the best practice to localize asp mvc apps, I saw

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.