删除字符串中的无效XML字符

时间:2016-03-07 20:03:22

标签: c# xml

我想要一种从XML字符串中捕获所有无效XML字符的简单方法。 sol,far我找不到任何捕获XML中所有无效字符的东西。 我使用的是.Net 4.0,这是我的字符串。

string abc = @"<Attribute key=""History"" value="" ....................................................&#x0A;3/4/2016 7:09:29 PM U.S. AZ (UTC/GMT -7), MEADORS, CY I:  (Pending Validation) (ME Review)&#x0A;Description: created/confirmed datasheet &amp; parameters in library datasheet folder &#x0D;&#x0A;\share1\PLATFORM_DESIGN\Hardware_Design\Library_Datasheets\ic\REQ42373&#x0A;&#x0A;&#x0A;....................................................&#x0A;3/4/2016 6:39:27 PM U.S. AZ (UTC/GMT -7), MEADORS, CY I:  (Pending Validation) (ME Review)&#x0A;Description: READY FOR MFG ENG review&#x0D;&#x0A;&#x0D;&#x0A;PASED LIBRARY review&#x0D;&#x0A;deleted un-used PROPERTIES (CLIP_DRAWING)&#x0D;&#x0A;confirmed DFA_DEV_CLASS = SUB50&#x0D;&#x0A;PHYSICAL checked: &#x0D;&#x0A;confirmed DRAWING LOCKED = TRUE&#x0D;&#x0A;Is the body size at least as big as the maximum body size on the datasheet? yes  (2.9x3.15)&#x0D;&#x0A;Are the pins numbered correctly according to the datasheet? yes &#x0D;&#x0A;Is the pitch of the symbol the same as the pitch of the part ? yes  (datasheet = 0.65)&#x0D;&#x0A;Is the width of the pad at least the same width of the max lead? yes &#x0D;&#x0A;Is pin 1 identified in silkscreen? yes  (circles, plus assembly top circle)&#x0D;&#x0A;Is there a placebound top shape extending .1MM from body edge? yes &#x0D;&#x0A;Is the height correctly indicated in the placebound top shape? yes  1.3mm&#x0D;&#x0A;Is the ref des correct for symbol type (parts with center die pad use EU)? yes -- U* &#x0D;&#x0A;Is there a solid shape matching body outline in Package_Geometry, Dfa_Bound_Top, plus pins? yes &#x0D;&#x0A;Does the symbol have a DFA_Class assigned? yes-- DFA_DEV_CLASS = SUB50 &#x0D;&#x0A;Pitch &lt;50 mils &#x0D;&#x0A;Is the symbol toe to toe at least 50 mils greater than the part toe to toe rounded to the nearest 10 mils? &#x0D;&#x0A;4.25mm + 1.27 (50 mil) = 5.52mmm --- 5.53 on symbol &#x0D;&#x0A;Is the symbol heel to heel at least 30 mils less than the part heel to heel or 10 mils less than part min body (whichever is greater) rounded down to the nearest 10 mils? &#x0D;&#x0A;Heel-to-heel 1.788 (70 mil) or 2.446 (98mil) compared to 2.285mm (90mil) on symbol &#x0D;&#x0A;Has the lock property been applied to the symbol? yes&#x0D;&#x0A;&#x0A;&#x0A;&#x0A;....................................................&#x0A;3/4/2016 6:17:09 PM U.S. AZ (UTC/GMT -7), MEADORS, CY I:  (Pending Validation) (Library Review)&#x0A;Description: added SUBCLASS &quot;lib_rev&quot; , added text REV1&#x0A;&#x0A;&#x0A;....................................................&#x0A;3/4/2016 6:16:19 PM U.S. AZ (UTC/GMT -7), MEADORS, CY I:  (Pending Validation) (Library Review)&#x0A;Description: PHYSICAL: missing LIB_REV subclass&#x0A;&#x0A;&#x0A;....................................................&#x0A;3/4/2016 6:10:56 PM U.S. AZ (UTC/GMT -7), MEADORS, CY I:  (Pending Validation) (Library Review)&#x0A;Description: Schematic symbol: &#x0D;&#x0A;Does the symbol pinout match package specified by DE?  yes (DCT package for SSOP)&#x0D;&#x0A;Is the correct IPN/REQ# for the part in the part properties? Yes  (PTF entry: placeholder REQ42373)&#x0D;&#x0A;Does the symbol have BOM, Device, Finance, IPN, Lead Free, MFR, MFR P/N, PART_NUMBER, ROOM and NO_STUFF properties in the part properties?  yes (known exception: no BOM, LEAD FREE, FINANCE property)&#x0D;&#x0A;Do all the properties in the symbol match the datasheet and/or SPEED? yes: match datasheet (DCT package for SSOP) &#x0D;&#x0A;Is the ref des correct for the part type?  yes: U* &#x0D;&#x0A;Is the correct mechanical symbol in PTF entry? yes: PTF entry w\new PHYSICAL: sSOP8_P65MM_2P8X2P95_1P3H&#x0D;&#x0A;Has the pin organization been okayed by the DE?  yes: matches typical in datasheet &#x0D;&#x0A;Are all the pins on grid? yes &#x0D;&#x0A;Does the symbol package? yes: packaged successfully &#x0D;&#x0A;Has the symbol been double-checked after a 24hr waiting period? (Or a second person double-checked the symbol?) &#x0D;&#x0A;peer reviewed  &#x0D;&#x0A;&#x0D;&#x0A;&#x0A;&#x0A;&#x0A;....................................................&#x0A;3/4/2016 4:55:29 PM U.S. AZ (UTC/GMT -7), MEADORS, CY I:  (Pending Validation) (Library Review)&#x0A;Description: peer review:&#x0D;&#x0A;LOGICAL : removed V from pin text (inside body) for NC pin 7&#x0A;&#x0A;&#x0A;....................................................&#x0A;3/4/2016 4:54:07 PM U.S. AZ (UTC/GMT -7), MEADORS, CY I:  (Pending Validation) (DE Review)&#x0A;Description: placeholder Part Number&#x0D;&#x0A;verbal approval by Jim Yoder for LOGICAL symbol&#x0D;&#x0A;&#x01; &#x02;&#x11;&#x12;&#x01; &#x04;&#x09;&#x04;&#x0B;&#x13;&#x0D;&#x0A; &#x02;&#x14;&#x08;&#x01;&#x0E;&#x0F;&#x0A;&#x0A;&#x0A;....................................................&#x0A;3/4/2016 11:11:03 AM U.S. AZ (UTC/GMT -7), MAGALLANES, J. L:  (Pending Validation) (Stakeholder(s) Review)&#x0A;Description: Ready for DE, ME and Peer review.&#x0D;&#x0A;Schematic symbol:&#x0D;&#x0A;1&#x09;Does the symbol pinout match package specified by DE?&#x09;Yes&#x0D;&#x0A;2&#x09;Is the correct IPN/REQ# for the part in the part properties?&#x09;Yes&#x0D;&#x0A;3&#x09;Does the symbol have BOM, Device, Finance, IPN, Lead Free, MFR, MFR P/N, PART_NUMBER, ROOM and NO_STUFF properties in the part properties?&#x09;Yes&#x0D;&#x0A;4&#x09;Do all the properties in the symbol match the datasheet and/or SPEED?&#x09;Yes&#x0D;&#x0A;5&#x09;Is the ref des correct for the part type?&#x09;Yes&#x0D;&#x0A;6&#x09;Is the correct mechanical symbol in the package properties?&#x09;Yes&#x0D;&#x0A;7&#x09;Has the pin organization been okayed by the DE?&#x09;No&#x0D;&#x0A;8&#x09;Are all the pins on grid?&#x09;Yes&#x0D;&#x0A;9&#x09;Does the symbol package?&#x09;Yes&#x0D;&#x0A;10&#x09;Has the symbol been double-checked after a 24hr waiting period? (Or a second person double-checked the symbol?)&#x09;No&#x0D;&#x0A;Footprint:&#x0D;&#x0A;1&#x09;Is the body size at least as big as the maximum body size on the datasheet?&#x09;Yes&#x0D;&#x0A;2&#x09;Are the pins numbered correctly according to the datasheet?&#x09;Yes&#x0D;&#x0A;3&#x09;Is the pitch of the symbol the same as the pitch of the part?&#x09;Yes&#x0D;&#x0A;4&#x09;Is the width of the pad at least the same width of the max lead?&#x09;Yes&#x0D;&#x0A;5&#x09;Is pin 1 identified in silkscreen?&#x09;Yes&#x0D;&#x0A;6&#x09;Is there a placebound top shape extending .1MM from body edge?&#x09;Yes&#x0D;&#x0A;7&#x09;Is the height correctly indicated in the placebound top shape?&#x09;&#x0D;&#x0A;8&#x09;Is the ref des correct for symbol type (parts with center die pad use EU)?&#x09;Yes&#x0D;&#x0A;9&#x09;Is there a solid shape matching body outline in Package_Geometry, Dfa_Bound_Top, plus pins?&#x09;Yes&#x0D;&#x0A;10&#x09;Does the symbol have a DFA_Class assigned?&#x09;Yes&#x0D;&#x0A;11&#x09;Pitch &lt;50 mils&#x09;Yes&#x0D;&#x0A;12&#x09;Is the symbol toe to toe at least 50 mils greater than the part toe to toe rounded to the nearest 10 mils?&#x09;Yes&#x0D;&#x0A;13&#x09;Is the symbol heel to heel at least 30 mils less than the part heel to heel or 10 mils less than part min body (whichever is greater) rounded down to the nearest 10 mils?&#x09;Yes&#x0D;&#x0A;15&#x09;Pitch &gt;50 mils&#x09;N/A&#x0D;&#x0A;16&#x09;Is the symbol toe to toe at least 30 mils greater than the part toe to toe rounded to the nearest 10 mils?&#x09;N/A&#x0D;&#x0A;17&#x09;Is the symbol heel to heel at least 30 mils less than the part heel to heel or 10 mils less than part min body (whichever is greater) rounded down to the nearest 10 mils?&#x09;N/A&#x0D;&#x0A;19&#x09;Pitch with &lt;.165 MM airgap&#x09;N/A&#x0D;&#x0A;20&#x09;Is there soldermask clearance equaling metal pattern plus gaps between adjacent pads?&#x09;N/A&#x0D;&#x0A;21&#x09;Is there route keepout top where there is soldermask clearance between adjacent pins?&#x09;N/A&#x0D;&#x0A;22&#x09;Has the lock property been applied to the symbol?&#x09;Yes&#x0D;&#x0A;&#x0A;&#x0A;&#x0A;....................................................&#x0A;3/2/2016 5:50:51 PM U.S. AZ (UTC/GMT -7), MAGALLANES, J. L:  (Active) (In Process)&#x0A;Description: Names added for Schematic symbol and Footprint.&#x0A;&#x0A;&#x0A;....................................................&#x0A;3/2/2016 5:39:32 PM U.S. AZ (UTC/GMT -7), MAGALLANES, J. L:  (Active) (In Process)&#x0A;Description: In Process of creation.&#x0A;&#x0A;&#x0A;....................................................&#x0A;2/22/2016 3:55:00 PM U.S. AZ (UTC/GMT -7), YODER, JIM :  (New) (New)&#x0A;Description: new symbols&#x0A;&#x0A;Attached file: TI ts5a2053""/>";

我正在使用以下代码

    var xmlPattern = "[^\u0001-\uD7FF\uE000-\uFFFD\ud800\udc00-\udbff\udfff]";

var newXml = xml.replace(new RegExp(xmlPattern , "g"), "");

但它没有抓住&#x01; &#x02;

我检查了herehere但没人帮忙。 编辑:- 这是完整的程序

    using System;
using System.Collections.Generic;
using System.Net.Mail;
using System.Globalization;
using System.Xml.Linq;
using System.Text.RegularExpressions;
using System.Text;
using System.Xml;
using System.Net;

class Program
{

    static void Main()
    {
        string abc = @"<Attribute key=""History"" value="" ....................................................&#x0A;3/4/2016 7:09:29 PM U.S. AZ (UTC/GMT -7), MEADORS, CY I:  (Pending Validation) (ME Review)&#x0A;Description: created/confirmed datasheet &amp; parameters in library datasheet folder &#x0D;&#x0A;\share1\PLATFORM_DESIGN\Hardware_Design\Library_Datasheets\ic\REQ42373&#x0A;&#x0A;&#x0A;....................................................&#x0A;3/4/2016 6:39:27 PM U.S. AZ (UTC/GMT -7), MEADORS, CY I:  (Pending Validation) (ME Review)&#x0A;Description: READY FOR MFG ENG review&#x0D;&#x0A;&#x0D;&#x0A;PASED LIBRARY review&#x0D;&#x0A;deleted un-used PROPERTIES (CLIP_DRAWING)&#x0D;&#x0A;confirmed DFA_DEV_CLASS = SUB50&#x0D;&#x0A;PHYSICAL checked: &#x0D;&#x0A;confirmed DRAWING LOCKED = TRUE&#x0D;&#x0A;Is the body size at least as big as the maximum body size on the datasheet? yes  (2.9x3.15)&#x0D;&#x0A;Are the pins numbered correctly according to the datasheet? yes &#x0D;&#x0A;Is the pitch of the symbol the same as the pitch of the part ? yes  (datasheet = 0.65)&#x0D;&#x0A;Is the width of the pad at least the same width of the max lead? yes &#x0D;&#x0A;Is pin 1 identified in silkscreen? yes  (circles, plus assembly top circle)&#x0D;&#x0A;Is there a placebound top shape extending .1MM from body edge? yes &#x0D;&#x0A;Is the height correctly indicated in the placebound top shape? yes  1.3mm&#x0D;&#x0A;Is the ref des correct for symbol type (parts with center die pad use EU)? yes -- U* &#x0D;&#x0A;Is there a solid shape matching body outline in Package_Geometry, Dfa_Bound_Top, plus pins? yes &#x0D;&#x0A;Does the symbol have a DFA_Class assigned? yes-- DFA_DEV_CLASS = SUB50 &#x0D;&#x0A;Pitch &lt;50 mils &#x0D;&#x0A;Is the symbol toe to toe at least 50 mils greater than the part toe to toe rounded to the nearest 10 mils? &#x0D;&#x0A;4.25mm + 1.27 (50 mil) = 5.52mmm --- 5.53 on symbol &#x0D;&#x0A;Is the symbol heel to heel at least 30 mils less than the part heel to heel or 10 mils less than part min body (whichever is greater) rounded down to the nearest 10 mils? &#x0D;&#x0A;Heel-to-heel 1.788 (70 mil) or 2.446 (98mil) compared to 2.285mm (90mil) on symbol &#x0D;&#x0A;Has the lock property been applied to the symbol? yes&#x0D;&#x0A;&#x0A;&#x0A;&#x0A;....................................................&#x0A;3/4/2016 6:17:09 PM U.S. AZ (UTC/GMT -7), MEADORS, CY I:  (Pending Validation) (Library Review)&#x0A;Description: added SUBCLASS &quot;lib_rev&quot; , added text REV1&#x0A;&#x0A;&#x0A;....................................................&#x0A;3/4/2016 6:16:19 PM U.S. AZ (UTC/GMT -7), MEADORS, CY I:  (Pending Validation) (Library Review)&#x0A;Description: PHYSICAL: missing LIB_REV subclass&#x0A;&#x0A;&#x0A;....................................................&#x0A;3/4/2016 6:10:56 PM U.S. AZ (UTC/GMT -7), MEADORS, CY I:  (Pending Validation) (Library Review)&#x0A;Description: Schematic symbol: &#x0D;&#x0A;Does the symbol pinout match package specified by DE?  yes (DCT package for SSOP)&#x0D;&#x0A;Is the correct IPN/REQ# for the part in the part properties? Yes  (PTF entry: placeholder REQ42373)&#x0D;&#x0A;Does the symbol have BOM, Device, Finance, IPN, Lead Free, MFR, MFR P/N, PART_NUMBER, ROOM and NO_STUFF properties in the part properties?  yes (known exception: no BOM, LEAD FREE, FINANCE property)&#x0D;&#x0A;Do all the properties in the symbol match the datasheet and/or SPEED? yes: match datasheet (DCT package for SSOP) &#x0D;&#x0A;Is the ref des correct for the part type?  yes: U* &#x0D;&#x0A;Is the correct mechanical symbol in PTF entry? yes: PTF entry w\new PHYSICAL: sSOP8_P65MM_2P8X2P95_1P3H&#x0D;&#x0A;Has the pin organization been okayed by the DE?  yes: matches typical in datasheet &#x0D;&#x0A;Are all the pins on grid? yes &#x0D;&#x0A;Does the symbol package? yes: packaged successfully &#x0D;&#x0A;Has the symbol been double-checked after a 24hr waiting period? (Or a second person double-checked the symbol?) &#x0D;&#x0A;peer reviewed  &#x0D;&#x0A;&#x0D;&#x0A;&#x0A;&#x0A;&#x0A;....................................................&#x0A;3/4/2016 4:55:29 PM U.S. AZ (UTC/GMT -7), MEADORS, CY I:  (Pending Validation) (Library Review)&#x0A;Description: peer review:&#x0D;&#x0A;LOGICAL : removed V from pin text (inside body) for NC pin 7&#x0A;&#x0A;&#x0A;....................................................&#x0A;3/4/2016 4:54:07 PM U.S. AZ (UTC/GMT -7), MEADORS, CY I:  (Pending Validation) (DE Review)&#x0A;Description: placeholder Part Number&#x0D;&#x0A;verbal approval by Jim Yoder for LOGICAL symbol&#x0D;&#x0A;&#x01; &#x02;&#x11;&#x12;&#x01; &#x04;&#x09;&#x04;&#x0B;&#x13;&#x0D;&#x0A; &#x02;&#x14;&#x08;&#x01;&#x0E;&#x0F;&#x0A;&#x0A;&#x0A;....................................................&#x0A;3/4/2016 11:11:03 AM U.S. AZ (UTC/GMT -7), MAGALLANES, J. L:  (Pending Validation) (Stakeholder(s) Review)&#x0A;Description: Ready for DE, ME and Peer review.&#x0D;&#x0A;Schematic symbol:&#x0D;&#x0A;1&#x09;Does the symbol pinout match package specified by DE?&#x09;Yes&#x0D;&#x0A;2&#x09;Is the correct IPN/REQ# for the part in the part properties?&#x09;Yes&#x0D;&#x0A;3&#x09;Does the symbol have BOM, Device, Finance, IPN, Lead Free, MFR, MFR P/N, PART_NUMBER, ROOM and NO_STUFF properties in the part properties?&#x09;Yes&#x0D;&#x0A;4&#x09;Do all the properties in the symbol match the datasheet and/or SPEED?&#x09;Yes&#x0D;&#x0A;5&#x09;Is the ref des correct for the part type?&#x09;Yes&#x0D;&#x0A;6&#x09;Is the correct mechanical symbol in the package properties?&#x09;Yes&#x0D;&#x0A;7&#x09;Has the pin organization been okayed by the DE?&#x09;No&#x0D;&#x0A;8&#x09;Are all the pins on grid?&#x09;Yes&#x0D;&#x0A;9&#x09;Does the symbol package?&#x09;Yes&#x0D;&#x0A;10&#x09;Has the symbol been double-checked after a 24hr waiting period? (Or a second person double-checked the symbol?)&#x09;No&#x0D;&#x0A;Footprint:&#x0D;&#x0A;1&#x09;Is the body size at least as big as the maximum body size on the datasheet?&#x09;Yes&#x0D;&#x0A;2&#x09;Are the pins numbered correctly according to the datasheet?&#x09;Yes&#x0D;&#x0A;3&#x09;Is the pitch of the symbol the same as the pitch of the part?&#x09;Yes&#x0D;&#x0A;4&#x09;Is the width of the pad at least the same width of the max lead?&#x09;Yes&#x0D;&#x0A;5&#x09;Is pin 1 identified in silkscreen?&#x09;Yes&#x0D;&#x0A;6&#x09;Is there a placebound top shape extending .1MM from body edge?&#x09;Yes&#x0D;&#x0A;7&#x09;Is the height correctly indicated in the placebound top shape?&#x09;&#x0D;&#x0A;8&#x09;Is the ref des correct for symbol type (parts with center die pad use EU)?&#x09;Yes&#x0D;&#x0A;9&#x09;Is there a solid shape matching body outline in Package_Geometry, Dfa_Bound_Top, plus pins?&#x09;Yes&#x0D;&#x0A;10&#x09;Does the symbol have a DFA_Class assigned?&#x09;Yes&#x0D;&#x0A;11&#x09;Pitch &lt;50 mils&#x09;Yes&#x0D;&#x0A;12&#x09;Is the symbol toe to toe at least 50 mils greater than the part toe to toe rounded to the nearest 10 mils?&#x09;Yes&#x0D;&#x0A;13&#x09;Is the symbol heel to heel at least 30 mils less than the part heel to heel or 10 mils less than part min body (whichever is greater) rounded down to the nearest 10 mils?&#x09;Yes&#x0D;&#x0A;15&#x09;Pitch &gt;50 mils&#x09;N/A&#x0D;&#x0A;16&#x09;Is the symbol toe to toe at least 30 mils greater than the part toe to toe rounded to the nearest 10 mils?&#x09;N/A&#x0D;&#x0A;17&#x09;Is the symbol heel to heel at least 30 mils less than the part heel to heel or 10 mils less than part min body (whichever is greater) rounded down to the nearest 10 mils?&#x09;N/A&#x0D;&#x0A;19&#x09;Pitch with &lt;.165 MM airgap&#x09;N/A&#x0D;&#x0A;20&#x09;Is there soldermask clearance equaling metal pattern plus gaps between adjacent pads?&#x09;N/A&#x0D;&#x0A;21&#x09;Is there route keepout top where there is soldermask clearance between adjacent pins?&#x09;N/A&#x0D;&#x0A;22&#x09;Has the lock property been applied to the symbol?&#x09;Yes&#x0D;&#x0A;&#x0A;&#x0A;&#x0A;....................................................&#x0A;3/2/2016 5:50:51 PM U.S. AZ (UTC/GMT -7), MAGALLANES, J. L:  (Active) (In Process)&#x0A;Description: Names added for Schematic symbol and Footprint.&#x0A;&#x0A;&#x0A;....................................................&#x0A;3/2/2016 5:39:32 PM U.S. AZ (UTC/GMT -7), MAGALLANES, J. L:  (Active) (In Process)&#x0A;Description: In Process of creation.&#x0A;&#x0A;&#x0A;....................................................&#x0A;2/22/2016 3:55:00 PM U.S. AZ (UTC/GMT -7), YODER, JIM :  (New) (New)&#x0A;Description: new symbols&#x0A;&#x0A;Attached file: TI ts5a2053""/>";
        CleanInvalidXmlChars(abc);
        Console.WriteLine(XElement.Parse(abc));

    }
    public static string CleanInvalidXmlChars(string text)   
 {   
   string Pattern=@"#x((10?|[2-F])FFF[EF]|FDD[0-9A-F]|7F|8[0-46-9A-F]9[0-9A-F])";
   string newString = string.Empty;
   Regex regex = new Regex(Pattern, RegexOptions.IgnoreCase);
   if (regex.IsMatch(text))
        newString=regex.Replace(text, "");   

     return newString.ToString();

 }  
}

2 个答案:

答案 0 :(得分:0)

不要替换它们 - 使用CDATA-Section允许它们 CDATA-Section MSDN

答案 1 :(得分:0)

对于初学者,请注意您的函数CleanInvalidXmlChars()会返回一个新字符串,但您没有对此字符串执行任何操作。此外,xml版本可能是1.1,因此它需要不同的字符过滤器。请试试这段代码......

static void Main()
{
    string abc = @"<Attribute key=""History"" value="" ....................................................&#x0A;3/4/2016 7:09:29 PM U.S. AZ (UTC/GMT -7), MEADORS, CY I:  (Pending Validation) (ME Review)&#x0A;Description: created/confirmed datasheet &amp; parameters in library datasheet folder &#x0D;&#x0A;\share1\PLATFORM_DESIGN\Hardware_Design\Library_Datasheets\ic\REQ42373&#x0A;&#x0A;&#x0A;....................................................&#x0A;3/4/2016 6:39:27 PM U.S. AZ (UTC/GMT -7), MEADORS, CY I:  (Pending Validation) (ME Review)&#x0A;Description: READY FOR MFG ENG review&#x0D;&#x0A;&#x0D;&#x0A;PASED LIBRARY review&#x0D;&#x0A;deleted un-used PROPERTIES (CLIP_DRAWING)&#x0D;&#x0A;confirmed DFA_DEV_CLASS = SUB50&#x0D;&#x0A;PHYSICAL checked: &#x0D;&#x0A;confirmed DRAWING LOCKED = TRUE&#x0D;&#x0A;Is the body size at least as big as the maximum body size on the datasheet? yes  (2.9x3.15)&#x0D;&#x0A;Are the pins numbered correctly according to the datasheet? yes &#x0D;&#x0A;Is the pitch of the symbol the same as the pitch of the part ? yes  (datasheet = 0.65)&#x0D;&#x0A;Is the width of the pad at least the same width of the max lead? yes &#x0D;&#x0A;Is pin 1 identified in silkscreen? yes  (circles, plus assembly top circle)&#x0D;&#x0A;Is there a placebound top shape extending .1MM from body edge? yes &#x0D;&#x0A;Is the height correctly indicated in the placebound top shape? yes  1.3mm&#x0D;&#x0A;Is the ref des correct for symbol type (parts with center die pad use EU)? yes -- U* &#x0D;&#x0A;Is there a solid shape matching body outline in Package_Geometry, Dfa_Bound_Top, plus pins? yes &#x0D;&#x0A;Does the symbol have a DFA_Class assigned? yes-- DFA_DEV_CLASS = SUB50 &#x0D;&#x0A;Pitch &lt;50 mils &#x0D;&#x0A;Is the symbol toe to toe at least 50 mils greater than the part toe to toe rounded to the nearest 10 mils? &#x0D;&#x0A;4.25mm + 1.27 (50 mil) = 5.52mmm --- 5.53 on symbol &#x0D;&#x0A;Is the symbol heel to heel at least 30 mils less than the part heel to heel or 10 mils less than part min body (whichever is greater) rounded down to the nearest 10 mils? &#x0D;&#x0A;Heel-to-heel 1.788 (70 mil) or 2.446 (98mil) compared to 2.285mm (90mil) on symbol &#x0D;&#x0A;Has the lock property been applied to the symbol? yes&#x0D;&#x0A;&#x0A;&#x0A;&#x0A;....................................................&#x0A;3/4/2016 6:17:09 PM U.S. AZ (UTC/GMT -7), MEADORS, CY I:  (Pending Validation) (Library Review)&#x0A;Description: added SUBCLASS &quot;lib_rev&quot; , added text REV1&#x0A;&#x0A;&#x0A;....................................................&#x0A;3/4/2016 6:16:19 PM U.S. AZ (UTC/GMT -7), MEADORS, CY I:  (Pending Validation) (Library Review)&#x0A;Description: PHYSICAL: missing LIB_REV subclass&#x0A;&#x0A;&#x0A;....................................................&#x0A;3/4/2016 6:10:56 PM U.S. AZ (UTC/GMT -7), MEADORS, CY I:  (Pending Validation) (Library Review)&#x0A;Description: Schematic symbol: &#x0D;&#x0A;Does the symbol pinout match package specified by DE?  yes (DCT package for SSOP)&#x0D;&#x0A;Is the correct IPN/REQ# for the part in the part properties? Yes  (PTF entry: placeholder REQ42373)&#x0D;&#x0A;Does the symbol have BOM, Device, Finance, IPN, Lead Free, MFR, MFR P/N, PART_NUMBER, ROOM and NO_STUFF properties in the part properties?  yes (known exception: no BOM, LEAD FREE, FINANCE property)&#x0D;&#x0A;Do all the properties in the symbol match the datasheet and/or SPEED? yes: match datasheet (DCT package for SSOP) &#x0D;&#x0A;Is the ref des correct for the part type?  yes: U* &#x0D;&#x0A;Is the correct mechanical symbol in PTF entry? yes: PTF entry w\new PHYSICAL: sSOP8_P65MM_2P8X2P95_1P3H&#x0D;&#x0A;Has the pin organization been okayed by the DE?  yes: matches typical in datasheet &#x0D;&#x0A;Are all the pins on grid? yes &#x0D;&#x0A;Does the symbol package? yes: packaged successfully &#x0D;&#x0A;Has the symbol been double-checked after a 24hr waiting period? (Or a second person double-checked the symbol?) &#x0D;&#x0A;peer reviewed  &#x0D;&#x0A;&#x0D;&#x0A;&#x0A;&#x0A;&#x0A;....................................................&#x0A;3/4/2016 4:55:29 PM U.S. AZ (UTC/GMT -7), MEADORS, CY I:  (Pending Validation) (Library Review)&#x0A;Description: peer review:&#x0D;&#x0A;LOGICAL : removed V from pin text (inside body) for NC pin 7&#x0A;&#x0A;&#x0A;....................................................&#x0A;3/4/2016 4:54:07 PM U.S. AZ (UTC/GMT -7), MEADORS, CY I:  (Pending Validation) (DE Review)&#x0A;Description: placeholder Part Number&#x0D;&#x0A;verbal approval by Jim Yoder for LOGICAL symbol&#x0D;&#x0A;&#x01; &#x02;&#x11;&#x12;&#x01; &#x04;&#x09;&#x04;&#x0B;&#x13;&#x0D;&#x0A; &#x02;&#x14;&#x08;&#x01;&#x0E;&#x0F;&#x0A;&#x0A;&#x0A;....................................................&#x0A;3/4/2016 11:11:03 AM U.S. AZ (UTC/GMT -7), MAGALLANES, J. L:  (Pending Validation) (Stakeholder(s) Review)&#x0A;Description: Ready for DE, ME and Peer review.&#x0D;&#x0A;Schematic symbol:&#x0D;&#x0A;1&#x09;Does the symbol pinout match package specified by DE?&#x09;Yes&#x0D;&#x0A;2&#x09;Is the correct IPN/REQ# for the part in the part properties?&#x09;Yes&#x0D;&#x0A;3&#x09;Does the symbol have BOM, Device, Finance, IPN, Lead Free, MFR, MFR P/N, PART_NUMBER, ROOM and NO_STUFF properties in the part properties?&#x09;Yes&#x0D;&#x0A;4&#x09;Do all the properties in the symbol match the datasheet and/or SPEED?&#x09;Yes&#x0D;&#x0A;5&#x09;Is the ref des correct for the part type?&#x09;Yes&#x0D;&#x0A;6&#x09;Is the correct mechanical symbol in the package properties?&#x09;Yes&#x0D;&#x0A;7&#x09;Has the pin organization been okayed by the DE?&#x09;No&#x0D;&#x0A;8&#x09;Are all the pins on grid?&#x09;Yes&#x0D;&#x0A;9&#x09;Does the symbol package?&#x09;Yes&#x0D;&#x0A;10&#x09;Has the symbol been double-checked after a 24hr waiting period? (Or a second person double-checked the symbol?)&#x09;No&#x0D;&#x0A;Footprint:&#x0D;&#x0A;1&#x09;Is the body size at least as big as the maximum body size on the datasheet?&#x09;Yes&#x0D;&#x0A;2&#x09;Are the pins numbered correctly according to the datasheet?&#x09;Yes&#x0D;&#x0A;3&#x09;Is the pitch of the symbol the same as the pitch of the part?&#x09;Yes&#x0D;&#x0A;4&#x09;Is the width of the pad at least the same width of the max lead?&#x09;Yes&#x0D;&#x0A;5&#x09;Is pin 1 identified in silkscreen?&#x09;Yes&#x0D;&#x0A;6&#x09;Is there a placebound top shape extending .1MM from body edge?&#x09;Yes&#x0D;&#x0A;7&#x09;Is the height correctly indicated in the placebound top shape?&#x09;&#x0D;&#x0A;8&#x09;Is the ref des correct for symbol type (parts with center die pad use EU)?&#x09;Yes&#x0D;&#x0A;9&#x09;Is there a solid shape matching body outline in Package_Geometry, Dfa_Bound_Top, plus pins?&#x09;Yes&#x0D;&#x0A;10&#x09;Does the symbol have a DFA_Class assigned?&#x09;Yes&#x0D;&#x0A;11&#x09;Pitch &lt;50 mils&#x09;Yes&#x0D;&#x0A;12&#x09;Is the symbol toe to toe at least 50 mils greater than the part toe to toe rounded to the nearest 10 mils?&#x09;Yes&#x0D;&#x0A;13&#x09;Is the symbol heel to heel at least 30 mils less than the part heel to heel or 10 mils less than part min body (whichever is greater) rounded down to the nearest 10 mils?&#x09;Yes&#x0D;&#x0A;15&#x09;Pitch &gt;50 mils&#x09;N/A&#x0D;&#x0A;16&#x09;Is the symbol toe to toe at least 30 mils greater than the part toe to toe rounded to the nearest 10 mils?&#x09;N/A&#x0D;&#x0A;17&#x09;Is the symbol heel to heel at least 30 mils less than the part heel to heel or 10 mils less than part min body (whichever is greater) rounded down to the nearest 10 mils?&#x09;N/A&#x0D;&#x0A;19&#x09;Pitch with &lt;.165 MM airgap&#x09;N/A&#x0D;&#x0A;20&#x09;Is there soldermask clearance equaling metal pattern plus gaps between adjacent pads?&#x09;N/A&#x0D;&#x0A;21&#x09;Is there route keepout top where there is soldermask clearance between adjacent pins?&#x09;N/A&#x0D;&#x0A;22&#x09;Has the lock property been applied to the symbol?&#x09;Yes&#x0D;&#x0A;&#x0A;&#x0A;&#x0A;....................................................&#x0A;3/2/2016 5:50:51 PM U.S. AZ (UTC/GMT -7), MAGALLANES, J. L:  (Active) (In Process)&#x0A;Description: Names added for Schematic symbol and Footprint.&#x0A;&#x0A;&#x0A;....................................................&#x0A;3/2/2016 5:39:32 PM U.S. AZ (UTC/GMT -7), MAGALLANES, J. L:  (Active) (In Process)&#x0A;Description: In Process of creation.&#x0A;&#x0A;&#x0A;....................................................&#x0A;2/22/2016 3:55:00 PM U.S. AZ (UTC/GMT -7), YODER, JIM :  (New) (New)&#x0A;Description: new symbols&#x0A;&#x0A;Attached file: TI ts5a2053""/>";
    XElement xml = ParseXml(abc);
    Console.WriteLine(xml);
}
private static XElement ParseXml(string text)
{
    XElement xml = null;
    try
    {
        xml = ParseXml(text, 1.0f);
    }
    catch(Exception)
    {
        xml = ParseXml(text, 1.1f);
    }
    return xml;
}

private static XElement ParseXml(string text, float xmlVersion)
{
    string newString = CleanInvalidXmlChars(text, xmlVersion);
    return XElement.Parse(newString);
}

private static string CleanInvalidXmlChars(string text, float xmlVersion)
{
    const string patternVersion1_0 = @"&#x((10?|[2-F])FFF[EF]|FDD[0-9A-F]|7F|8[0-46-9A-F]9[0-9A-F]);";
    const string patternVersion1_1 = @"&#x((10?|[2-F])FFF[EF]|FDD[0-9A-F]|[19][0-9A-F]|7F|8[0-46-9A-F]|0?[1-8BCEF]);";
    string Pattern = xmlVersion == 1.0f ? patternVersion1_0 : patternVersion1_1;
    string newString = string.Empty;
    Regex regex = new Regex(Pattern, RegexOptions.IgnoreCase);
    if (regex.IsMatch(text))
        newString = regex.Replace(text, "");
    else
        newString = text;

    return newString.ToString();

}