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
- RichTextBoxConstants.cs
- FormConverter.cs
- AdPostCacheSubstitution.cs
- LogSwitch.cs
- CheckableControlBaseAdapter.cs
- CultureSpecificStringDictionary.cs
- ProfileSettings.cs
- ProcessMonitor.cs
- TextInfo.cs
- SystemUdpStatistics.cs
- DateTimeOffsetStorage.cs
- ApplicationCommands.cs
- HtmlInputText.cs
- RectangleHotSpot.cs
- EventTrigger.cs
- DataGridViewSelectedColumnCollection.cs
- TextReturnReader.cs
- PaginationProgressEventArgs.cs
- mediaclock.cs
- ReadOnlyActivityGlyph.cs
- DispatcherHooks.cs
- XmlSortKeyAccumulator.cs
- DataServiceQueryOfT.cs
- RemoteWebConfigurationHostStream.cs
- UnsafeNativeMethods.cs
- DataBinder.cs
- SystemDropShadowChrome.cs
- ExpressionContext.cs
- WebPartManagerInternals.cs
- TextWriter.cs
- GenericUriParser.cs
- SamlConditions.cs
- HitTestResult.cs
- PermissionAttributes.cs
- NameScope.cs
- TypeConverterHelper.cs
- DropDownHolder.cs
- InputBuffer.cs
- Tuple.cs
- SymmetricCryptoHandle.cs
- ToolStripComboBox.cs
- Calendar.cs
- NonParentingControl.cs
- DbDataSourceEnumerator.cs
- RegularExpressionValidator.cs
- BindingExpression.cs
- BamlResourceContent.cs
- WorkflowElementDialog.cs
- HtmlToClrEventProxy.cs
- FormViewUpdatedEventArgs.cs
- XmlSchemaInclude.cs
- FormViewDeleteEventArgs.cs
- SoapMessage.cs
- GenericRootAutomationPeer.cs
- HtmlTable.cs
- AssemblyNameProxy.cs
- ContourSegment.cs
- XmlReaderSettings.cs
- MessagePropertyVariants.cs
- ModuleBuilder.cs
- EpmHelper.cs
- WorkflowInstanceExtensionProvider.cs
- WSIdentityFaultException.cs
- Point3D.cs
- DigestTraceRecordHelper.cs
- securitymgrsite.cs
- TouchesOverProperty.cs
- ScrollProperties.cs
- MetadataArtifactLoaderCompositeResource.cs
- MdiWindowListItemConverter.cs
- BindingParameterCollection.cs
- GlyphElement.cs
- SQlBooleanStorage.cs
- Timeline.cs
- SpinWait.cs
- SequenceDesigner.cs
- MasterPageBuildProvider.cs
- AutomationIdentifierGuids.cs
- TrustManagerPromptUI.cs
- CollectionBase.cs
- SelectionPattern.cs
- Style.cs
- SoapReflectionImporter.cs
- RadialGradientBrush.cs
- BulletedList.cs
- Translator.cs
- DataGridViewAutoSizeColumnsModeEventArgs.cs
- TypeElement.cs
- ReturnEventArgs.cs
- XhtmlBasicCommandAdapter.cs
- BlockUIContainer.cs
- WhitespaceRuleReader.cs
- UnsafeNativeMethodsMilCoreApi.cs
- OrCondition.cs
- ByteAnimationUsingKeyFrames.cs
- DataGridViewHeaderCell.cs
- BasicBrowserDialog.cs
- DbProviderManifest.cs
- ConfigXmlText.cs
- XmlMessageFormatter.cs