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)

'Declaration
<AttributeUsageAttribute(AttributeTargets.All)> _
Public NotInheritable Class MatchAttribute _
	Inherits Attribute
'Usage
Dim instance As MatchAttribute

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 [<topic://cpconcreatingclientsthatparsecontentofotherwebpages>].

Imports System
Imports System.Web.Services.Protocols


Public Class MatchAttribute_Example
    Inherits HttpGetClientProtocol

    Public Sub New()
        Url = "http://localhost" 
    End Sub 'New

    <HttpMethodAttribute(GetType(TextReturnReader), GetType(UrlParameterWriter))> _
    Public Function GetHeaders() As Headers
        Return CType(Invoke("GetHeaders", Url + "/MyHeaders.html", New Object(0) {}), Headers)
    End Function 'GetHeaders


    Public Function BeginGetHeaders(ByVal callback As System.AsyncCallback, ByVal asyncState As Object) As _
                                                                         System.IAsyncResult
        Return BeginInvoke("GetHeaders", Url + "/MyHeaders.html", New Object(0) {}, _
                                                                          callback, asyncState)
    End Function 'BeginGetHeaders


    Public Function EndGetHeaders(ByVal asyncResult As System.IAsyncResult) As Headers
        Return CType(EndInvoke(asyncResult), Headers)
    End Function 'EndGetHeaders
End Class 'MatchAttribute_Example    

Public Class Headers

    <MatchAttribute("TITLE>(.*?)<")> _
    Public Title As String

    <MatchAttribute("", Pattern:="h1>(.*?)<", IgnoreCase:=True)> _
    Public H1 As String

    <MatchAttribute("H2>((([^<,]*),?)+)<", Group:=3, Capture:=4)> _
    Public Element As String

    <MatchAttribute("H2>((([^<,]*),?){2,})<", Group:=3, MaxRepeats:=0)> _
    Public Elements1() As String

    <MatchAttribute("H2>((([^<,]*),?){2,})<", Group:=3, MaxRepeats:=1)> _
    Public Elements2() As String

    <MatchAttribute("H3 ([^=]*)=([^>]*)", Group:=1)> _
    Public Attribute As String

    <MatchAttribute("H3 ([^=]*)=([^>]*)", Group:=2)> _
    Public Value As String 
End Class 'Headers
#using <mscorlib.dll>
#using <System.dll>
#using <System.Web.Services.dll>
using namespace System;
using namespace System::Web::Services::Protocols;
   public __gc class Example_Headers {
   public:
      [MatchAttribute(S"TITLE>(.?)<")]
      String* Title;

      [MatchAttribute(S"", Pattern=S"h1>(.?)<", IgnoreCase=true)]
      String* H1;

      [MatchAttribute(S"H2>(((->Item[^<, ]*), ?)+)<", Group=3, Capture=4)]
      String* Element;

      [MatchAttribute(S"H2>(((->Item[^<, ]*), ?) {2, })<", Group=3, MaxRepeats=0)]
      String* Elements1[];

      [MatchAttribute(S"H2>(((->Item[^<, ]*), ?) {2, })<", Group=3, MaxRepeats=1)]
      String* Elements2[];

      [MatchAttribute(S"H3 (->Item[^=]*)=(->Item[^>]*)", Group=1)]
      String* Attribute;

      [MatchAttribute(S"H3 (->Item[^=]*)=(->Item[^>]*)", Group=2)]
      String* Value;
   };

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 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft