Strip Non Valid XML Characters. : Schema « XML « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Date Time
8.Design Patterns
9.Development Class
10.Event
11.File Stream
12.Generics
13.GUI Windows Form
14.Internationalization I18N
15.Language Basics
16.LINQ
17.Network
18.Office
19.Reflection
20.Regular Expressions
21.Security
22.Services Event
23.Thread
24.Web Services
25.Windows
26.Windows Presentation Foundation
27.XML
28.XML LINQ
C# Book
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » XML » SchemaScreenshots 
Strip Non Valid XML Characters.
   

//http://facebooktoolkit.codeplex.com/
//http://facebooktoolkit.codeplex.com/license
using System.Collections.Generic;
using System.Text;

namespace Facebook.Utility
{
    /// <summary>
    /// Helper functions for string manipulation
    /// </summary>
    public static class StringHelper
    {
        /// <summary>
        /// Strip Non Valid XML Characters.
        /// </summary>
        public static string StripNonValidXMLCharacters(string s)
        {
            StringBuilder _validXML = new StringBuilder(s.Length, s.Length)// Used to hold the output.
            char[] charArray = s.ToCharArray();

            if (string.IsNullOrEmpty(s)) return string.Empty; // vacancy test.

            for (int i = 0; i < charArray.Length; i++)
            {
                char current = charArray[i];
                if ((current == 0x9||
                (current == 0xA||
                (current == 0xD||
                ((current >= 0x20&& (current <= 0xD7FF)) ||
                ((current >= 0xE000&& (current <= 0xFFFD)))
                    _validXML.Append(current);
            }
            return _validXML.ToString();
        }
   }
}        

   
    
    
  
Related examples in the same category
1.Set XmlReaderSettings
2.Choose ValidationType
3.Validate an XML Document Against a Schema
4.Validate Schema
5.Use XML schema to validate XML documents
6.Use XmlReaderSettings to validate the Xml document
7.Is Well Formed Xml
8.XmlSchema is an in-memory representation of an XML Schema
9.Is Xml Valid
10.Xml Validation Helper
11.Get Intrinsic Simple Types Names from System.Xml.Schema.DatatypeImplementation
12.Reads a XML schema file and returns the information found in that.
13.XML reading functionality
java2s.com  |  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.