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
- ResourcesGenerator.cs
- ComplexTypeEmitter.cs
- ListViewGroupConverter.cs
- LayoutTable.cs
- NativeMethods.cs
- FixedDocumentPaginator.cs
- UidManager.cs
- CombinedHttpChannel.cs
- FrameworkElement.cs
- OdbcErrorCollection.cs
- Repeater.cs
- VirtualizingPanel.cs
- TcpChannelHelper.cs
- unsafeIndexingFilterStream.cs
- Convert.cs
- ToolStripInSituService.cs
- HitTestParameters3D.cs
- GridProviderWrapper.cs
- ContractNamespaceAttribute.cs
- CultureInfoConverter.cs
- TdsParserStaticMethods.cs
- SliderAutomationPeer.cs
- EntityDataSourceSelectedEventArgs.cs
- GetResponse.cs
- LineBreakRecord.cs
- SqlDataReader.cs
- SystemIPv4InterfaceProperties.cs
- XPathItem.cs
- TagPrefixCollection.cs
- SystemColors.cs
- InfoCardTraceRecord.cs
- SchemaCollectionCompiler.cs
- DataObject.cs
- PageThemeBuildProvider.cs
- PageThemeParser.cs
- HtmlInputImage.cs
- ClientFormsIdentity.cs
- ArrayList.cs
- __Error.cs
- DateTimeParse.cs
- JsonServiceDocumentSerializer.cs
- CallbackValidator.cs
- FileEnumerator.cs
- MetadataWorkspace.cs
- Block.cs
- LogSwitch.cs
- JsonGlobals.cs
- AttachedPropertyBrowsableWhenAttributePresentAttribute.cs
- BrowserDefinitionCollection.cs
- GeometryHitTestParameters.cs
- DispatchWrapper.cs
- DataGridViewCellEventArgs.cs
- FormsIdentity.cs
- RepeatInfo.cs
- KeyboardDevice.cs
- AdPostCacheSubstitution.cs
- OLEDB_Util.cs
- CodeDomComponentSerializationService.cs
- VScrollProperties.cs
- XmlUtilWriter.cs
- HMACSHA1.cs
- UnmanagedHandle.cs
- ComponentResourceKeyConverter.cs
- ControlCollection.cs
- StandardCommands.cs
- PasswordBox.cs
- GridViewColumnHeaderAutomationPeer.cs
- Environment.cs
- NullRuntimeConfig.cs
- NavigationPropertyEmitter.cs
- SQLMoney.cs
- InvalidDataException.cs
- WinFormsSecurity.cs
- Pen.cs
- GacUtil.cs
- StructuralType.cs
- TickBar.cs
- InfoCardAsymmetricCrypto.cs
- SqlCacheDependencyDatabase.cs
- Semaphore.cs
- SqlClientFactory.cs
- _CacheStreams.cs
- FileVersionInfo.cs
- AccessText.cs
- BitmapPalettes.cs
- CodeIterationStatement.cs
- RadialGradientBrush.cs
- documentsequencetextview.cs
- NonSerializedAttribute.cs
- ItemDragEvent.cs
- DataControlPagerLinkButton.cs
- TrustLevel.cs
- JobDuplex.cs
- DataPagerCommandEventArgs.cs
- GridViewPageEventArgs.cs
- DataObject.cs
- TransactionManager.cs
- BitmapPalettes.cs
- SelectionList.cs
- ClaimTypes.cs