XPathQueryGenerator Class
When given a class representing a data contract, and metadata representing a member of the contract, produces an XPath query for the member.
Assembly: System.Runtime.Serialization (in System.Runtime.Serialization.dll)
| Name | Description | |
|---|---|---|
![]() ![]() | CreateFromDataContractSerializer(Type, array<MemberInfo>, XmlNamespaceManager%) | Creates an XPath from a data contract using the specified data contract type, array of metadata elements, and namespaces.. |
![]() ![]() | CreateFromDataContractSerializer(Type, array<MemberInfo>, StringBuilder, XmlNamespaceManager%) | Creates an XPath from a data contract using the specified contract data type, array of metadata elements, the top level element, and namespaces. |
For more information about data contracts, see Using Data Contracts.
To use the class, there are four steps:
Create the data contract type by applying the DataContractAttribute and DataMemberAttribute as appropriate to the type and its fields or properties.
Use the GetMember() method of the Type class to generate the MemberInfo array.
Pass the type and the array to the method.
If needed, use the XmlNamespaceManager returned by the namespaces parameter to examine the XML namespaces referenced by the namespaces prefixes in the XPath query.
Note |
|---|
The namespace prefix "xg" (for "XPath Generator") is used as the default in the XPath. This cannot be changed. Instead, refer to the NameTable collection to see what namespace the prefix is associated with. |
The following example creates XPath queries from two classes to which the DataContractAttribute and DataMemberAttribute attributes have been applied.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
