Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- GraphicsState.cs
- MinimizableAttributeTypeConverter.cs
- ConfigXmlSignificantWhitespace.cs
- Int32Storage.cs
- StructuralCache.cs
- AppDomainGrammarProxy.cs
- SecurityValidationBehavior.cs
- ArgumentOutOfRangeException.cs
- KeyInfo.cs
- XslAstAnalyzer.cs
- HMACMD5.cs
- DashStyles.cs
- ObjectNavigationPropertyMapping.cs
- DataGridViewCellLinkedList.cs
- NumericUpDown.cs
- KeySplineConverter.cs
- SqlOuterApplyReducer.cs
- Win32.cs
- DataControlField.cs
- FormsAuthentication.cs
- SamlSerializer.cs
- DetailsViewModeEventArgs.cs
- InvalidEnumArgumentException.cs
- Claim.cs
- XamlSerializer.cs
- RoutedEventHandlerInfo.cs
- ObservableDictionary.cs
- TextTreeUndoUnit.cs
- BrowserCapabilitiesCodeGenerator.cs
- BulletDecorator.cs
- XmlSignatureProperties.cs
- Registry.cs
- RuntimeWrappedException.cs
- ClickablePoint.cs
- FormViewCommandEventArgs.cs
- TextServicesPropertyRanges.cs
- ComponentEditorForm.cs
- MapPathBasedVirtualPathProvider.cs
- SimpleApplicationHost.cs
- ListViewItem.cs
- Utils.cs
- ComplexBindingPropertiesAttribute.cs
- DropDownList.cs
- FrameworkObject.cs
- Fault.cs
- smtpconnection.cs
- ByteConverter.cs
- ToolStripPanelRenderEventArgs.cs
- TTSEvent.cs
- BlurBitmapEffect.cs
- OracleMonthSpan.cs
- TextParentUndoUnit.cs
- ManagementObject.cs
- SerialErrors.cs
- EpmSyndicationContentDeSerializer.cs
- safex509handles.cs
- MouseEvent.cs
- ShapingWorkspace.cs
- DependencyPropertyAttribute.cs
- CardSpaceException.cs
- SchemaMapping.cs
- BufferCache.cs
- Registry.cs
- WebPartConnectionsCancelVerb.cs
- CodeDelegateInvokeExpression.cs
- FontSource.cs
- BrowserDefinitionCollection.cs
- Vector.cs
- ToolStripMenuItem.cs
- HtmlInputReset.cs
- Rectangle.cs
- DocumentPaginator.cs
- ContentPosition.cs
- XamlRtfConverter.cs
- XmlSchemaComplexContentExtension.cs
- ProxyFragment.cs
- SystemInfo.cs
- DataTableReader.cs
- StylusButton.cs
- Main.cs
- embossbitmapeffect.cs
- remotingproxy.cs
- TextEditorTyping.cs
- MatrixIndependentAnimationStorage.cs
- ConstraintConverter.cs
- PtsHost.cs
- HtmlGenericControl.cs
- UserNameSecurityTokenProvider.cs
- CompilerCollection.cs
- ElementHost.cs
- CallbackValidator.cs
- InputLanguageEventArgs.cs
- ComponentCollection.cs
- cache.cs
- ResourceAssociationSetEnd.cs
- QuaternionConverter.cs
- EDesignUtil.cs
- EmissiveMaterial.cs
- MailSettingsSection.cs
- sqlnorm.cs