Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- ContourSegment.cs
- SmtpMail.cs
- ArgumentException.cs
- SqlTrackingWorkflowInstance.cs
- CompilationLock.cs
- OdbcConnectionString.cs
- WaitHandle.cs
- DSASignatureFormatter.cs
- EmptyEnumerator.cs
- WeakRefEnumerator.cs
- TextTreeRootNode.cs
- MD5CryptoServiceProvider.cs
- DesignTimeTemplateParser.cs
- TextDecoration.cs
- RuleSet.cs
- SqlError.cs
- VideoDrawing.cs
- ELinqQueryState.cs
- MailAddressCollection.cs
- CredentialManagerDialog.cs
- CodeDirectoryCompiler.cs
- AuthenticationModuleElement.cs
- NamedObject.cs
- precedingsibling.cs
- AnnotationAdorner.cs
- TrackingWorkflowEventArgs.cs
- RijndaelManaged.cs
- RouteCollection.cs
- CachedRequestParams.cs
- TextRange.cs
- ColorTransformHelper.cs
- ipaddressinformationcollection.cs
- BinaryKeyIdentifierClause.cs
- AssemblyInfo.cs
- Validator.cs
- TrustManager.cs
- SelectionRangeConverter.cs
- ToolStripDropDownMenu.cs
- PrivateFontCollection.cs
- ClrProviderManifest.cs
- ObjectSecurity.cs
- BitVector32.cs
- TextEffectCollection.cs
- EncryptedData.cs
- SimpleApplicationHost.cs
- XamlFigureLengthSerializer.cs
- SessionStateSection.cs
- PageStatePersister.cs
- ConfigUtil.cs
- SystemEvents.cs
- EntityDataSourceContextDisposingEventArgs.cs
- FacetChecker.cs
- Environment.cs
- DirectionalLight.cs
- WebPartDescriptionCollection.cs
- CodeSubDirectory.cs
- RegexCapture.cs
- WinInet.cs
- SchemaCreator.cs
- DataReceivedEventArgs.cs
- QueryBranchOp.cs
- IpcManager.cs
- MiniModule.cs
- FillBehavior.cs
- ErrorHandler.cs
- ComplexBindingPropertiesAttribute.cs
- ConditionalWeakTable.cs
- AutoResetEvent.cs
- RuntimeVariableList.cs
- RSAOAEPKeyExchangeDeformatter.cs
- CompilerTypeWithParams.cs
- DataControlFieldHeaderCell.cs
- Assembly.cs
- ExecutionScope.cs
- TextWriter.cs
- WindowsPrincipal.cs
- SoapCodeExporter.cs
- ActivityTypeResolver.xaml.cs
- TreeViewAutomationPeer.cs
- CachedBitmap.cs
- FormViewPageEventArgs.cs
- WebHeaderCollection.cs
- RadioButtonList.cs
- TagMapCollection.cs
- ImageInfo.cs
- Permission.cs
- Condition.cs
- PersonalizableAttribute.cs
- UserControlCodeDomTreeGenerator.cs
- LogicalExpressionEditor.cs
- MetadataArtifactLoaderCompositeResource.cs
- DBSchemaTable.cs
- SQLDecimalStorage.cs
- Animatable.cs
- XmlArrayItemAttributes.cs
- BinaryUtilClasses.cs
- TemplateControlCodeDomTreeGenerator.cs
- DataGridTextBox.cs
- RuntimeResourceSet.cs
- Activity.cs