Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SqlNodeTypeOperators.cs
- InfoCard.cs
- UpdateException.cs
- DataGridViewTextBoxCell.cs
- MonthCalendar.cs
- DataGridViewEditingControlShowingEventArgs.cs
- IOThreadTimer.cs
- ErrorRuntimeConfig.cs
- SpeakProgressEventArgs.cs
- RelatedCurrencyManager.cs
- BehaviorEditorPart.cs
- SectionUpdates.cs
- HtmlString.cs
- WindowsToolbarAsMenu.cs
- TraceProvider.cs
- CodeNamespaceImport.cs
- CharConverter.cs
- RectIndependentAnimationStorage.cs
- Lookup.cs
- PersonalizableTypeEntry.cs
- TabControlCancelEvent.cs
- SystemException.cs
- figurelength.cs
- WebConfigurationManager.cs
- GiveFeedbackEventArgs.cs
- ServiceBusyException.cs
- PackUriHelper.cs
- RoutedCommand.cs
- StringKeyFrameCollection.cs
- EntityDesignerUtils.cs
- MonthCalendar.cs
- ListView.cs
- SoapCommonClasses.cs
- CodeNamespaceImport.cs
- RoamingStoreFile.cs
- RawStylusInputCustomData.cs
- IListConverters.cs
- InputEventArgs.cs
- RadioButtonPopupAdapter.cs
- TypeContext.cs
- TextElementEditingBehaviorAttribute.cs
- RtfToXamlReader.cs
- PolyBezierSegment.cs
- XmlQueryContext.cs
- RotationValidation.cs
- unsafeIndexingFilterStream.cs
- VisualTreeUtils.cs
- InputScopeAttribute.cs
- DataSysAttribute.cs
- ByteStreamGeometryContext.cs
- BaseCodePageEncoding.cs
- WebHttpDispatchOperationSelector.cs
- XmlSchemaElement.cs
- DataGridAddNewRow.cs
- MethodAccessException.cs
- RtfNavigator.cs
- ProtocolsConfigurationHandler.cs
- SqlCommandSet.cs
- SqlConnectionPoolGroupProviderInfo.cs
- ConfigurationValidatorAttribute.cs
- JoinGraph.cs
- SystemException.cs
- BitmapSource.cs
- StylusButtonEventArgs.cs
- CircleHotSpot.cs
- MessageDroppedTraceRecord.cs
- TypeElementCollection.cs
- ISessionStateStore.cs
- EditingMode.cs
- JoinCqlBlock.cs
- UpdateCommandGenerator.cs
- WebPartZoneBase.cs
- MulticastNotSupportedException.cs
- ResourceProperty.cs
- AddInController.cs
- BinaryObjectInfo.cs
- PolyLineSegmentFigureLogic.cs
- OleCmdHelper.cs
- Cell.cs
- InputEventArgs.cs
- X509UI.cs
- ComboBox.cs
- MetadataCache.cs
- FixedSchema.cs
- DesignerTransactionCloseEvent.cs
- SqlDeflator.cs
- TreeNodeStyleCollection.cs
- BinaryParser.cs
- BufferedConnection.cs
- OverflowException.cs
- CapabilitiesState.cs
- TransformProviderWrapper.cs
- WebPartDescription.cs
- Int64.cs
- ArithmeticException.cs
- XmlRawWriter.cs
- EntityDataSourceState.cs
- XmlSchemaObjectTable.cs
- Pair.cs
- PixelShader.cs