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
- XmlDocument.cs
- Int16AnimationBase.cs
- DependencyObjectPropertyDescriptor.cs
- ExpressionConverter.cs
- DataSetUtil.cs
- TreeNodeClickEventArgs.cs
- SQLInt16Storage.cs
- BitmapDownload.cs
- ControlPersister.cs
- PathStreamGeometryContext.cs
- DecimalConstantAttribute.cs
- TemplatedEditableDesignerRegion.cs
- ComboBox.cs
- TypeGeneratedEventArgs.cs
- Parameter.cs
- CustomAttributeFormatException.cs
- PathSegment.cs
- SynchronizedPool.cs
- SqlProfileProvider.cs
- ContentDisposition.cs
- EventsTab.cs
- SspiHelper.cs
- FontFamilyValueSerializer.cs
- TransactionInterop.cs
- ProxyHelper.cs
- HoistedLocals.cs
- ListViewGroupConverter.cs
- CreateUserWizardDesigner.cs
- DesignerActionTextItem.cs
- HttpMethodAttribute.cs
- CharAnimationUsingKeyFrames.cs
- MarshalByValueComponent.cs
- FontStyle.cs
- EntityDataSourceContextCreatingEventArgs.cs
- SQLInt16Storage.cs
- TextContainerChangeEventArgs.cs
- cache.cs
- RegexCompiler.cs
- DataSvcMapFile.cs
- InputEventArgs.cs
- CodeFieldReferenceExpression.cs
- RouteParametersHelper.cs
- FlowDocumentPage.cs
- _AutoWebProxyScriptHelper.cs
- ColorConverter.cs
- PackageRelationshipCollection.cs
- RealizationContext.cs
- UnhandledExceptionEventArgs.cs
- XmlILModule.cs
- FtpRequestCacheValidator.cs
- NavigationEventArgs.cs
- _ChunkParse.cs
- CatalogPartChrome.cs
- MatrixConverter.cs
- ProgressBar.cs
- ProxyManager.cs
- XmlDataSource.cs
- StringFunctions.cs
- Win32SafeHandles.cs
- HtmlEncodedRawTextWriter.cs
- WindowsSecurityTokenAuthenticator.cs
- SHA256.cs
- DataGridViewRowsAddedEventArgs.cs
- RegexCapture.cs
- Error.cs
- DrawingCollection.cs
- EntityDataSourceWrapper.cs
- SourceFileBuildProvider.cs
- LinqDataSourceInsertEventArgs.cs
- IndicFontClient.cs
- ReflectionTypeLoadException.cs
- CollectionContainer.cs
- HttpProfileBase.cs
- DataControlFieldHeaderCell.cs
- SamlSubjectStatement.cs
- ComplexBindingPropertiesAttribute.cs
- Events.cs
- DependencyProperty.cs
- RadialGradientBrush.cs
- XsltSettings.cs
- KeyboardEventArgs.cs
- HybridDictionary.cs
- ResourceIDHelper.cs
- SoapObjectReader.cs
- BindingGroup.cs
- ConstrainedGroup.cs
- KeyGestureConverter.cs
- TypeConverterMarkupExtension.cs
- WindowsScrollBarBits.cs
- AndCondition.cs
- XmlnsDictionary.cs
- RadioButtonBaseAdapter.cs
- CommandHelper.cs
- SingleStorage.cs
- StylusShape.cs
- TraceUtility.cs
- FragmentNavigationEventArgs.cs
- TemplateNameScope.cs
- TextRunProperties.cs
- ExpressionContext.cs