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
- VSWCFServiceContractGenerator.cs
- SaveFileDialog.cs
- PublisherIdentityPermission.cs
- RoleManagerEventArgs.cs
- BaseCodePageEncoding.cs
- SmtpMail.cs
- ExpandSegment.cs
- DesignerActionHeaderItem.cs
- ResourcePool.cs
- EmptyReadOnlyDictionaryInternal.cs
- SqlNotificationRequest.cs
- DBAsyncResult.cs
- MarshalByValueComponent.cs
- PolyQuadraticBezierSegment.cs
- AggregateNode.cs
- SmtpDigestAuthenticationModule.cs
- UncommonField.cs
- SurrogateSelector.cs
- Visual3D.cs
- AvTraceDetails.cs
- ReversePositionQuery.cs
- DataControlFieldCollection.cs
- UnsafePeerToPeerMethods.cs
- DWriteFactory.cs
- WebPartConnectionCollection.cs
- ipaddressinformationcollection.cs
- ProfileSection.cs
- SerializerProvider.cs
- ClientScriptItemCollection.cs
- SizeFConverter.cs
- ValueProviderWrapper.cs
- Property.cs
- HttpProfileGroupBase.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- RootContext.cs
- DataGridViewColumnCollectionEditor.cs
- XmlSignificantWhitespace.cs
- SendActivityEventArgs.cs
- cookieexception.cs
- CollectionEditorDialog.cs
- Resources.Designer.cs
- ApplicationGesture.cs
- InfoCardKeyedHashAlgorithm.cs
- FillBehavior.cs
- XmlSchemaCollection.cs
- ReflectEventDescriptor.cs
- DrawingVisualDrawingContext.cs
- StaticFileHandler.cs
- KeyGestureValueSerializer.cs
- DataGridBoolColumn.cs
- HtmlElementEventArgs.cs
- BitmapImage.cs
- UniformGrid.cs
- EventListenerClientSide.cs
- CheckedPointers.cs
- XslAstAnalyzer.cs
- StrongNameHelpers.cs
- OdbcConnectionOpen.cs
- HtmlInputRadioButton.cs
- NumericUpDownAccelerationCollection.cs
- ToolStripItemClickedEventArgs.cs
- TextTrailingCharacterEllipsis.cs
- ConnectionConsumerAttribute.cs
- ReadOnlyCollectionBase.cs
- XPathNodeIterator.cs
- Menu.cs
- QuaternionValueSerializer.cs
- TablePatternIdentifiers.cs
- Site.cs
- MouseGestureValueSerializer.cs
- CodeSubDirectoriesCollection.cs
- EventSinkHelperWriter.cs
- EntityContainerEmitter.cs
- QualificationDataAttribute.cs
- DataListItemEventArgs.cs
- InputBuffer.cs
- _BaseOverlappedAsyncResult.cs
- DoubleAnimationUsingPath.cs
- FieldAccessException.cs
- ResolveNextArgumentWorkItem.cs
- Binding.cs
- SchemaImporterExtensionElement.cs
- SiteMapDataSource.cs
- ProfileProvider.cs
- AssociationTypeEmitter.cs
- ModelUIElement3D.cs
- PowerStatus.cs
- RunClient.cs
- MediaScriptCommandRoutedEventArgs.cs
- RtfFormatStack.cs
- SrgsDocumentParser.cs
- MetadataUtilsSmi.cs
- ProbeDuplexAsyncResult.cs
- KeyGesture.cs
- IsolatedStorage.cs
- ZipIOEndOfCentralDirectoryBlock.cs
- HwndStylusInputProvider.cs
- MembershipSection.cs
- HttpCookiesSection.cs
- XmlSortKeyAccumulator.cs