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

Hi need help getting repeated value from give array,below is the code which im
Multi-Test TestNG.xml file results in java.lang.NullPointerException Hello Quality Team, I need help getting TestNG
I need help getting the firmware version from the output of the Cisco show
Using SQL Sever 2005 From the below Query Am getting total worked time means
I need to fetch java version 1.6.0_26 from the below java -version output java
I need some help getting the jquery cycle plugin to work as below: Basically,
I need help getting the menus below the red box to slide up instead
Need help getting Ember-Data working with Zend Rest. At first, I'm familiar with Zend
I need help getting CommonJS working on Java 7 and Rhino 1.7R3. Rhino 1.7R3
I need help getting VIM to correctly indent javascript inside script tags. This is

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.