Esporta (0) Stampa
Espandi tutto
Questo argomento non è stato ancora valutato - Valuta questo argomento

XmlNamespaceManager Class

Resolves, adds, and removes namespaces to a collection and provides scope management for these namespaces.

System.Object
  System.Xml.XmlNamespaceManager
    System.Xml.Xsl.XsltContext

Namespace:  System.Xml
Assembly:  System.Xml (in System.Xml.dll)
public class XmlNamespaceManager : IXmlNamespaceResolver, 
	IEnumerable

The XmlNamespaceManager type exposes the following members.

  NameDescription
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360XmlNamespaceManagerInitializes a new instance of the XmlNamespaceManager class with the specified XmlNameTable.
Top
  NameDescription
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360DefaultNamespaceGets the namespace URI for the default namespace.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360NameTableGets the XmlNameTable associated with this object.
Top
  NameDescription
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360AddNamespaceAdds the given namespace to the collection.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360Equals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneSupported by Xbox 360FinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360GetEnumeratorReturns an enumerator to use to iterate through the namespaces in the XmlNamespaceManager.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360GetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360GetNamespacesInScopeGets a collection of namespace names keyed by prefix which can be used to enumerate the namespaces currently in scope.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360GetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360HasNamespaceGets a value indicating whether the supplied prefix has a namespace defined for the current pushed scope.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360LookupNamespaceGets the namespace URI for the specified prefix.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360LookupPrefixFinds the prefix declared for the given namespace URI.
Protected methodSupported by Silverlight for Windows PhoneSupported by Xbox 360MemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360PopScopePops a namespace scope off the stack.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360PushScopePushes a namespace scope onto the stack.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360RemoveNamespaceRemoves the given namespace for the given prefix.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360ToStringReturns a string that represents the current object. (Inherited from Object.)
Top
  NameDescription
Public Extension MethodSupported by Silverlight for Windows PhoneAsQueryableConverts an IEnumerable to an IQueryable. (Defined by Queryable.)
Public Extension MethodSupported by Silverlight for Windows PhoneSupported by Xbox 360Cast<TResult>Converts the elements of an IEnumerable to the specified type. (Defined by Enumerable.)
Public Extension MethodSupported by Silverlight for Windows PhoneSupported by Xbox 360OfType<TResult>Filters the elements of an IEnumerable based on a specified type. (Defined by Enumerable.)
Top

XmlNamespaceManager stores prefixes and namespaces as strings.



                StringBuilder output = new StringBuilder();

                // Create the string containing the XML to read.
                String xmlFrag =
                    @"<root>
                        <data>
	                        <items>
		                        <item id='1'>
		                        </item>
	                        </items>
                        </data>
                        </root>";

                using (XmlReader reader = XmlReader.Create(new StringReader(xmlFrag)))
                {
                    XmlNamespaceManager nsmanager = new XmlNamespaceManager(reader.NameTable);
                    nsmanager.AddNamespace("msbooks", "www.microsoft.com/books");
                    nsmanager.PushScope();
                    nsmanager.AddNamespace("msstore", "www.microsoft.com/store");

                    foreach (String prefix in nsmanager)
                    {
                        output.AppendLine("Prefix" + prefix + " Namespace=" +
                            nsmanager.LookupNamespace(prefix));
                    }
                }
                OutputTextBlock.Text = output.ToString();


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

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

Aggiunte alla community

AGGIUNGI
Mostra:
© 2014 Microsoft. Tutti i diritti riservati.