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
- GrabHandleGlyph.cs
- DataGridColumnCollection.cs
- WindowsFormsDesignerOptionService.cs
- SqlDataSourceSelectingEventArgs.cs
- RewritingProcessor.cs
- UIPermission.cs
- XmlWriterDelegator.cs
- RectangleConverter.cs
- TransactionTable.cs
- KnownTypeHelper.cs
- BitArray.cs
- DataGridView.cs
- FileSystemInfo.cs
- AndCondition.cs
- ListSortDescriptionCollection.cs
- AddDataControlFieldDialog.cs
- TextParagraphProperties.cs
- CloseCollectionAsyncResult.cs
- HealthMonitoringSectionHelper.cs
- PartitionedStream.cs
- WebPartCancelEventArgs.cs
- ModelPerspective.cs
- ServiceEndpointAssociationProvider.cs
- IndexerNameAttribute.cs
- TypeExtensionSerializer.cs
- RC2.cs
- HandleExceptionArgs.cs
- TablePatternIdentifiers.cs
- SingleObjectCollection.cs
- XmlMemberMapping.cs
- _NetworkingPerfCounters.cs
- TextAnchor.cs
- PersonalizationAdministration.cs
- Speller.cs
- DataMember.cs
- ClientScriptManager.cs
- HealthMonitoringSection.cs
- SystemDiagnosticsSection.cs
- BuildDependencySet.cs
- DtdParser.cs
- CachedTypeface.cs
- Substitution.cs
- WebDescriptionAttribute.cs
- TdsParserStateObject.cs
- DataControlImageButton.cs
- XamlUtilities.cs
- odbcmetadatacollectionnames.cs
- SpinLock.cs
- ExternalDataExchangeService.cs
- MappingModelBuildProvider.cs
- TypedTableBase.cs
- StylusDownEventArgs.cs
- SlipBehavior.cs
- SwitchLevelAttribute.cs
- Single.cs
- BlurEffect.cs
- JpegBitmapDecoder.cs
- XmlSchemaSimpleType.cs
- EncryptedType.cs
- XmlStreamedByteStreamReader.cs
- X509ChainElement.cs
- LingerOption.cs
- SoapTypeAttribute.cs
- EmptyStringExpandableObjectConverter.cs
- WindowsBrush.cs
- CodeAttachEventStatement.cs
- TraceSwitch.cs
- SecurityCapabilities.cs
- DataGridComponentEditor.cs
- DesignTableCollection.cs
- ScrollProperties.cs
- FontEmbeddingManager.cs
- TraceData.cs
- EntityDesignerUtils.cs
- PointUtil.cs
- DotExpr.cs
- WmiEventSink.cs
- WorkflowWebHostingModule.cs
- XmlSchemaComplexContentRestriction.cs
- ObjectPersistData.cs
- CompatibleIComparer.cs
- VBIdentifierName.cs
- TypedTableBase.cs
- ChtmlTextWriter.cs
- PropertyChangeTracker.cs
- MD5CryptoServiceProvider.cs
- DataTableNewRowEvent.cs
- RuntimeArgumentHandle.cs
- XmlSchemaAttribute.cs
- TreeIterators.cs
- SqlCacheDependencyDatabase.cs
- GroupByExpressionRewriter.cs
- XmlSchemaRedefine.cs
- ApplicationInfo.cs
- RoleServiceManager.cs
- ValidatorAttribute.cs
- BasicHttpSecurityElement.cs
- MatcherBuilder.cs
- InputMethodStateTypeInfo.cs
- BasePropertyDescriptor.cs