Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Shared / MS / Internal / XmlHelper.cs / 1 / XmlHelper.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // Description: // Implements some helper functions for Xml nodes. // //--------------------------------------------------------------------------- using System; using System.Xml; #if WINDOWS_BASE using MS.Internal.WindowsBase; #elif PRESENTATION_CORE using MS.Internal.PresentationCore; #elif PRESENTATIONFRAMEWORK using MS.Internal.PresentationFramework; #elif DRT using MS.Internal.Drt; #else #error Attempt to use FriendAccessAllowedAttribute from an unknown assembly. using MS.Internal.YourAssemblyName; #endif namespace MS.Internal { [FriendAccessAllowed] static class XmlHelper { ////// Return true if the given item is an XML node. /// internal static bool IsXmlNode(object item) { if (item != null) { Type type = item.GetType(); return type.FullName.StartsWith("System.Xml", StringComparison.Ordinal) && IsXmlNodeHelper(item); } else return false; } // separate function to avoid JIT-ing System.Xml until we have a good reason private static bool IsXmlNodeHelper(object item) { return item is System.Xml.XmlNode; } ////// Return a string by applying an XPath query to an XmlNode. /// internal static string SelectStringValue(XmlNode node, string query) { return SelectStringValue(node, query, null); } ////// Return a string by applying an XPath query to an XmlNode. /// internal static string SelectStringValue(XmlNode node, string query, XmlNamespaceManager namespaceManager) { string strValue; XmlNode result; result = node.SelectSingleNode(query, namespaceManager); if (result != null) { strValue = XmlHelper.ExtractString(result); } else { strValue = String.Empty; } return strValue; } ////// Get a string from an XmlNode (of any kind: element, attribute, etc.) /// internal static string ExtractString(XmlNode node) { string value = ""; if (node.NodeType == XmlNodeType.Element) { for (int i = 0; i < node.ChildNodes.Count; i++) { if (node.ChildNodes[i].NodeType == XmlNodeType.Text) { value += node.ChildNodes[i].Value; } } } else { value = node.Value; } return value; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // Description: // Implements some helper functions for Xml nodes. // //--------------------------------------------------------------------------- using System; using System.Xml; #if WINDOWS_BASE using MS.Internal.WindowsBase; #elif PRESENTATION_CORE using MS.Internal.PresentationCore; #elif PRESENTATIONFRAMEWORK using MS.Internal.PresentationFramework; #elif DRT using MS.Internal.Drt; #else #error Attempt to use FriendAccessAllowedAttribute from an unknown assembly. using MS.Internal.YourAssemblyName; #endif namespace MS.Internal { [FriendAccessAllowed] static class XmlHelper { ////// Return true if the given item is an XML node. /// internal static bool IsXmlNode(object item) { if (item != null) { Type type = item.GetType(); return type.FullName.StartsWith("System.Xml", StringComparison.Ordinal) && IsXmlNodeHelper(item); } else return false; } // separate function to avoid JIT-ing System.Xml until we have a good reason private static bool IsXmlNodeHelper(object item) { return item is System.Xml.XmlNode; } ////// Return a string by applying an XPath query to an XmlNode. /// internal static string SelectStringValue(XmlNode node, string query) { return SelectStringValue(node, query, null); } ////// Return a string by applying an XPath query to an XmlNode. /// internal static string SelectStringValue(XmlNode node, string query, XmlNamespaceManager namespaceManager) { string strValue; XmlNode result; result = node.SelectSingleNode(query, namespaceManager); if (result != null) { strValue = XmlHelper.ExtractString(result); } else { strValue = String.Empty; } return strValue; } ////// Get a string from an XmlNode (of any kind: element, attribute, etc.) /// internal static string ExtractString(XmlNode node) { string value = ""; if (node.NodeType == XmlNodeType.Element) { for (int i = 0; i < node.ChildNodes.Count; i++) { if (node.ChildNodes[i].NodeType == XmlNodeType.Text) { value += node.ChildNodes[i].Value; } } } else { value = node.Value; } return value; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SynchronizedKeyedCollection.cs
- XPathDocumentNavigator.cs
- PagerSettings.cs
- DrawingAttributes.cs
- TimeZone.cs
- XmlMembersMapping.cs
- XmlCountingReader.cs
- LingerOption.cs
- Touch.cs
- WebFormDesignerActionService.cs
- XmlAttributeCache.cs
- PropertyTabAttribute.cs
- TableStyle.cs
- AccessText.cs
- KnownTypeAttribute.cs
- ControlBuilder.cs
- ErrorStyle.cs
- ServiceBuildProvider.cs
- WebPartEventArgs.cs
- HttpListenerTimeoutManager.cs
- XPathDocumentBuilder.cs
- ObfuscateAssemblyAttribute.cs
- UTF8Encoding.cs
- EntryPointNotFoundException.cs
- ConfigurationPropertyCollection.cs
- WorkflowFileItem.cs
- AxHostDesigner.cs
- Calendar.cs
- TrackingLocation.cs
- Size3DValueSerializer.cs
- IdentityReference.cs
- WsatTransactionHeader.cs
- XmlLanguageConverter.cs
- FixedDocumentPaginator.cs
- ListViewPagedDataSource.cs
- TabletCollection.cs
- EmbeddedObject.cs
- ParameterModifier.cs
- CertificateReferenceElement.cs
- EventTask.cs
- DetailsViewPageEventArgs.cs
- InheritanceAttribute.cs
- XmlTypeAttribute.cs
- AudioBase.cs
- FormView.cs
- KeyGestureValueSerializer.cs
- ButtonPopupAdapter.cs
- X509CertificateCollection.cs
- TagPrefixInfo.cs
- TextDecorations.cs
- CompositeDataBoundControl.cs
- PackageDigitalSignatureManager.cs
- RuleEngine.cs
- OutputCacheProfile.cs
- PeerName.cs
- ParameterRetriever.cs
- BindingGroup.cs
- ComponentRenameEvent.cs
- WpfKnownTypeInvoker.cs
- EmbossBitmapEffect.cs
- DaylightTime.cs
- PageRanges.cs
- ColumnResult.cs
- DirectoryInfo.cs
- BinaryObjectInfo.cs
- XhtmlBasicImageAdapter.cs
- DataKeyArray.cs
- WebScriptServiceHost.cs
- PlainXmlWriter.cs
- ReadOnlyCollectionBase.cs
- WindowsFormsHelpers.cs
- CanExecuteRoutedEventArgs.cs
- ButtonField.cs
- ByteRangeDownloader.cs
- BasicKeyConstraint.cs
- securitymgrsite.cs
- XPathBuilder.cs
- SchemaRegistration.cs
- Math.cs
- BitmapMetadata.cs
- WhitespaceRuleLookup.cs
- RegularExpressionValidator.cs
- PathFigureCollectionValueSerializer.cs
- CfgRule.cs
- GridViewAutomationPeer.cs
- GregorianCalendar.cs
- ArrangedElementCollection.cs
- DependencySource.cs
- TreeIterator.cs
- TransformerConfigurationWizardBase.cs
- CurrencyManager.cs
- Comparer.cs
- ISFTagAndGuidCache.cs
- ContainerParagraph.cs
- SafeTimerHandle.cs
- AttachmentService.cs
- CompileLiteralTextParser.cs
- TagElement.cs
- TreeViewDataItemAutomationPeer.cs
- CompilationUnit.cs