Export (0) Print
Expand All

MatchAttribute Class

Represents the attributes of a match made using text pattern matching. This class cannot be inherited.

Namespace: System.Web.Services.Protocols
Assembly: System.Web.Services (in system.web.services.dll)

[AttributeUsageAttribute(AttributeTargets.All)] 
public sealed class MatchAttribute : Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.All) */ 
public final class MatchAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.All) 
public final class MatchAttribute extends Attribute
Not applicable.

Text pattern matching allows an XML Web service to leverage existing HTML content by parsing it using regular expressions. an XML Web service specifies the content it wants to parse in a Service Description using match elements. These match elements specify several items: the regular expression for parsing the contents of an existing HTML page, whether the parsing must be case-insensitive, and how many instances of content that matches the regular expression should be returned. When a client builds a proxy class using the Wsdl.exe tool, methods of the proxy class include a MatchAttribute detailing the match elements found in the Service Description.

For more information on text pattern matching, see How to: Create Web Services That Parse the Contents of a Web Page.

using System;
using System.Web.Services.Protocols;

public class MatchAttribute_Example : HttpGetClientProtocol
{
	public MatchAttribute_Example()
	{
		Url = "http://localhost";
	}

	[HttpMethodAttribute(typeof(TextReturnReader), typeof(UrlParameterWriter))]
	public Example_Headers GetHeaders()
	{
		return ((Example_Headers)Invoke("GetHeaders", (Url + "/MyHeaders.html"),
			new object[0]));
	}

	public System.IAsyncResult BeginGetHeaders(System.AsyncCallback callback,
		object asyncState) 
	{
		return BeginInvoke("GetHeaders", (Url + "/MyHeaders.html"), 
			new object[0], callback, asyncState);
	}

	public Example_Headers EndGetHeaders(System.IAsyncResult asyncResult) 
	{
		return (Example_Headers)(EndInvoke(asyncResult));
	}
}
public class Example_Headers 
{    
	[MatchAttribute("TITLE>(.*?)<")]
	public string Title;
        
	[MatchAttribute("", Pattern="h1>(.*?)<", IgnoreCase=true)]
	public string H1;

	[MatchAttribute("H2>((([^<,]*),?)+)<", Group=3, Capture=4)] 
	public string Element;

	[MatchAttribute("H2>((([^<,]*),?){2,})<", Group=3, MaxRepeats=0)] 
	public string[] Elements1;

	[MatchAttribute("H2>((([^<,]*),?){2,})<", Group=3, MaxRepeats=1)] 
	public string[] Elements2;

	[MatchAttribute("H3 ([^=]*)=([^>]*)", Group=1)]
	public string Attribute;

	[MatchAttribute("H3 ([^=]*)=([^>]*)", Group=2)]
	public string Value;
}


import System.*;
import System.Web.Services.Protocols.*;

public class MatchAttribute_Example extends HttpGetClientProtocol
{
    public MatchAttribute_Example()
    {
        set_Url("http://localhost");
    } //MatchAttribute_Example

    /** @attribute HttpMethodAttribute(TextReturnReader.class, 
        UrlParameterWriter.class)
     */
    public Example_Headers GetHeaders()
    {
        return (Example_Headers)Invoke("GetHeaders", get_Url() 
            + "/MyHeaders.html", new Object[0]);
    } //GetHeaders

    public System.IAsyncResult BeginGetHeaders(System.AsyncCallback callback, 
        Object asyncState)
    {
        return BeginInvoke("GetHeaders", get_Url() 
            + "/MyHeaders.html", new Object[0], callback, asyncState);
    } //BeginGetHeaders

    public Example_Headers EndGetHeaders(System.IAsyncResult asyncResult)
    {
        return (Example_Headers)EndInvoke(asyncResult);
    } //EndGetHeaders
} //MatchAttribute_Example

public class Example_Headers
{
    /** @attribute MatchAttribute("TITLE>(.*?)<")
     */
    public String title;

    /** @attribute MatchAttribute("", Pattern = "h1>(.*?)<", IgnoreCase = true)
     */
    public String h1;

    /** @attribute MatchAttribute("H2>((([^<,]*),?)+)<", Group = 3, Capture = 4)
     */
    public String element;

    /** @attribute MatchAttribute("H2>((([^<,]*),?){2,})<", Group = 3, 
        MaxRepeats = 0)
     */
    public String elements1[];

    /** @attribute MatchAttribute("H2>((([^<,]*),?){2,})<", Group = 3, 
        MaxRepeats = 1)
     */
    public String elements2[];

    /** @attribute MatchAttribute("H3 ([^=]*)=([^>]*)", Group = 1)
     */
    public String attribute;

    /** @attribute MatchAttribute("H3 ([^=]*)=([^>]*)", Group = 2)
     */
    public String value;
} //Example_Headers

System.Object
   System.Attribute
    System.Web.Services.Protocols.MatchAttribute

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft