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
- DictionaryTraceRecord.cs
- ContextMenu.cs
- MarginsConverter.cs
- InvalidDataException.cs
- PropertyChangingEventArgs.cs
- DataListItemEventArgs.cs
- ConstraintManager.cs
- SystemWebCachingSectionGroup.cs
- Cursors.cs
- SectionVisual.cs
- SelectionRangeConverter.cs
- SafeRightsManagementHandle.cs
- WorkflowDebuggerSteppingAttribute.cs
- _BaseOverlappedAsyncResult.cs
- QueryCoreOp.cs
- SigningCredentials.cs
- TableLayoutCellPaintEventArgs.cs
- ResourceReader.cs
- InstanceData.cs
- RNGCryptoServiceProvider.cs
- WebZone.cs
- BindingsCollection.cs
- PropertyChangedEventManager.cs
- SqlCommand.cs
- ListBindableAttribute.cs
- MsmqProcessProtocolHandler.cs
- BaseComponentEditor.cs
- AuthenticationSection.cs
- StringValidatorAttribute.cs
- _IPv4Address.cs
- XmlChildEnumerator.cs
- TextProviderWrapper.cs
- Setter.cs
- BrowserDefinition.cs
- DynamicDiscoveryDocument.cs
- MainMenu.cs
- ResourcePermissionBase.cs
- Utils.cs
- DBParameter.cs
- Splitter.cs
- PointValueSerializer.cs
- ArglessEventHandlerProxy.cs
- ObservableCollection.cs
- WhileDesigner.cs
- HttpPostedFile.cs
- _IPv6Address.cs
- ConfigsHelper.cs
- InkCanvasSelection.cs
- SqlRetyper.cs
- WpfGeneratedKnownTypes.cs
- ScriptHandlerFactory.cs
- Line.cs
- WebHeaderCollection.cs
- CodeRemoveEventStatement.cs
- EarlyBoundInfo.cs
- BuildProvider.cs
- WebPartEditorOkVerb.cs
- XPathSelfQuery.cs
- MouseWheelEventArgs.cs
- SupportingTokenSpecification.cs
- WindowManager.cs
- TypefaceCollection.cs
- DtdParser.cs
- ListBindingHelper.cs
- TableDetailsRow.cs
- HtmlImage.cs
- AttributedMetaModel.cs
- StoryFragments.cs
- NotifyIcon.cs
- SystemIPv6InterfaceProperties.cs
- DataSourceControlBuilder.cs
- WrapPanel.cs
- ObjectDataSourceFilteringEventArgs.cs
- TemplateParser.cs
- UIElement3DAutomationPeer.cs
- JsonWriter.cs
- CodeTypeDeclarationCollection.cs
- SafeFindHandle.cs
- EnterpriseServicesHelper.cs
- PropertySegmentSerializationProvider.cs
- CrossAppDomainChannel.cs
- TypePresenter.xaml.cs
- StorageRoot.cs
- GACMembershipCondition.cs
- SessionStateModule.cs
- OutputCacheSettingsSection.cs
- FilterQueryOptionExpression.cs
- BamlBinaryReader.cs
- CellPartitioner.cs
- CollectionContainer.cs
- NetCodeGroup.cs
- ExceptionValidationRule.cs
- XhtmlBasicImageAdapter.cs
- EastAsianLunisolarCalendar.cs
- RtfToXamlLexer.cs
- PermissionAttributes.cs
- ForceCopyBuildProvider.cs
- BooleanProjectedSlot.cs
- _BufferOffsetSize.cs
- SafeNativeMethods.cs