Expression Web Queries

Posted by: Minal Agarwal , on 1/19/2010, in Category Expression Web
Views: 32542
Abstract: Queries in Expression Web to search and replace a particular pattern or factor could be required often while developing a website. The Find and Replace dialog box in Expression Web has much to offer, than the traditional find and replace mechanism. You can create queries for the same. In this article we would take a deep insight into how to create such queries to pinpoint any misses in the code and search and replace intelligently.
Expression Web Queries
Expression Web queries should be used to search and replace a particular pattern or expressions. It could be really helpful while developing a website to search and replace in a long and complicated codes. The Find and Replace dialog box was used to find a word or an expression and replace with another set. But in Expression Web, the Find and Replace tool has much more to offer, than the traditional search mechanism. You can create queries for the same.
In this article we would take a deep insight into how to create search queries, to run them and search and replace intelligently.
To create a query to find missing attributes
1.    Go to the Edit menu > Find or Replace to open the ‘Find and Replace’ dialog box.
2.    Switch to the ‘HTML Tags’ tab.
3.    Enter the following values:
·         Find Tag dropdown: img
·         Replace Action dropdown: Set attribute value
·         Attribute: alt
4.    Click on the ‘HTML Rules…’ button.
5.    In the HTML Rules dialog box, click on ‘New rule…’ In the New Rule dropdown, that appears in the bottom of the box, choose ‘Without attribute’ and in the [any attribute] dropdown, choose ‘alt’.
6.     The query description is always shown next to the Clear rules button in the Find and Replace dialog box. See image below:
7.    Click OK in HTML Rules dialog box. Click on the Save query button in the Find and Replace window (see highlighted button in the image above).
8.    The default location to save this query would be – ‘C:\Users\Username\AppData\Roaming\Microsoft\Expression\Web 3\Legacy\Expression\Web 3\Queries’
where C:\ would be your hard drive where and ‘Username’ would be your Windows username.
NOTE: If Queries folder does not exist, then create one in the same location or create your own folder at a simpler and easily accessible location.
Give a relevant name and save. The query will be saved with the extension ‘.fpq’.
9.    In the Find and Replace window, under the ‘Search options’ choose ‘All Pages’ and click ‘Find All’.
10.Expression Web will run the query and find all the <img> tags without the alt attribute and display it in the Find Task Pane or Panel (Task Panes are called as Panels in Expression Web 3) at the bottom on your workspace.
11.Since you have saved your query, you can use it again.
Reuse the query
We saved the query that we wrote above to reuse it later. To do that launch the Find and Replace dialog box (Edit > Find or Edit > Replace or CTRL + F or CTRL + H). On the HTML Tags tab click on the open the query icon (open folder icon next to Save query), browse to the Queries folder (path given above) choose the query and click Open. The query is now open in the Find and Replace dialog box.
Edit or Refine query search
The Find Panel when displays the results of the query, could be used to refine your search. Each column in the panel gives you option for Custom Filter as shown below:
As you choose (Custom…) the Custom AutoFilter dialog box is launched.
Set additional conditions to refine your search.
Some more options are also available when you right click on the results in the Find Panel, see image below:
Open a query as an xml
Queries are saved as ‘.fpq’. In the Windows Explorer/browser window, browse to the location of the query. Right click and choose ‘Open’. If you are opening this file type for the first time, then Windows will ask you to associate a program to open the file. See image below:
Choose ‘Select a program from a list of installed programs’ and click OK. In the ‘Open With’ dialog box, choose Notepad, make sure the ‘Always use the selected program to open this type of file’ option button is selected. Click OK.
The query will now be opened with a notepad and would look something like this:
<?xml version="1.0" encoding="utf-8" ?>
<fpquery version="1.0">
 <queryparams />
 <find tag="img">
    <rule type="attribute" attribute="alt" compare="=" value="" negate="true" />
 <replace type="setAttribute" attribute="alt" value="" />
You can save this xml and use the file in your pages.

I hope this article has thrown some light on Expression Web Query. So now you could use them to smartly reduce your efforts.

If you liked the article,  Subscribe to the RSS Feed or Subscribe Via Email

This article has been editorially reviewed by Suprotim Agarwal.

Absolutely Awesome Book on C# and .NET

C# and .NET have been around for a very long time, but their constant growth means there’s always more to learn.

We at DotNetCurry are very excited to announce The Absolutely Awesome Book on C# and .NET. This is a 500 pages concise technical eBook available in PDF, ePub (iPad), and Mobi (Kindle).

Organized around concepts, this Book aims to provide a concise, yet solid foundation in C# and .NET, covering C# 6.0, C# 7.0 and .NET Core, with chapters on the latest .NET Core 3.0, .NET Standard and C# 8.0 (final release) too. Use these concepts to deepen your existing knowledge of C# and .NET, to have a solid grasp of the latest in C# and .NET OR to crack your next .NET Interview.

Click here to Explore the Table of Contents or Download Sample Chapters!

What Others Are Reading!
Was this article worth reading? Share it with fellow developers too. Thanks!
Share on LinkedIn
Share on Google+

Minal Agarwal, Expression Web MVP, MCDST, works as a freelance web designer (SaffronStroke) working on Expression Web, Photoshop and other Graphical tools. As a hobby, she also runs a famous Food site called Follow her on twitter @ saffronstroke

Page copy protected against web site content infringement 	by Copyscape

Feedback - Leave us some adulation, criticism and everything in between!