1 C#将xml文档的节点转换成大写的形式

1 例如有xml文档

  

<?xml version="1.0" encoding="utf-8"?>
<EDISecurityMaster593Entity>
<SCEXHID position="0" type="int">the field ScexhIDlength more than max length</SCEXHID>
<SEDOLID position="1" type="int">the field SedolIDlength more than max length</SEDOLID>
<ACTFLAG position="2" maxlength="1" type="string">the field Actflaglength more than max length 1.</ACTFLAG>
<CHANGED position="3" maxlength="" type="datetime">the field Changedlength more than max length</CHANGED>
<CREATED position="4" maxlength="" type="datetime">the field Createdlength more than max length</CREATED>
<SECID position="5" type="int">the field SecIDlength more than max length</SECID>
<ISSID position="6" type="int">the field IssIDlength more than max length</ISSID>
<ISIN position="7" maxlength="12" type="string">the field ISINlength more than max length 12.</ISIN>
<USCODE position="8" maxlength="9" type="string">the field USCodelength more than max length 9.</USCODE>
<ISSUERNAME position="9" maxlength="70" type="string">the field IssuerNamelength more than max length 70.</ISSUERNAME>
<CNTRYOFINCORP position="10" maxlength="2" type="string">the field CntryofIncorplength more than max length 2.</CNTRYOFINCORP>
<SIC position="11" maxlength="10" type="string">the field SIClength more than max length 10.</SIC>
<CIK position="12" maxlength="10" type="string">the field CIKlength more than max length 10.</CIK>
<INDUSID position="13" type="int">the field IndusIDlength more than max length</INDUSID>
<SECTYCD position="14" maxlength="3" type="string">the field SectyCDlength more than max length 3.</SECTYCD>
<SECURITYDESC position="15" maxlength="70" type="string">the field SecurityDesclength more than max length 70.</SECURITYDESC>
<PARVALUE position="16" maxlength="" type="decimal">the field ParValuelength more than max length</PARVALUE>
<PVCURRENCY position="17" maxlength="3" type="string">the field PVCurrencylength more than max length 3.</PVCURRENCY>
<STATUSFLAG position="18" maxlength="1" type="string">the field StatusFlaglength more than max length 1.</STATUSFLAG>
<PRIMARYEXCHGCD position="19" maxlength="6" type="string">the field PrimaryExchgCDlength more than max length</PRIMARYEXCHGCD>
<SEDOL position="20" maxlength="7" type="string">the field Sedollength more than max length</SEDOL>
<SEDOLCURRENCY position="21" maxlength="2" type="string">the field SedolCurrencylength more than max length 3.</SEDOLCURRENCY>
<DEFUNCT position="22" maxlength="1" type="string">the field Defunctlength more than max length 1.</DEFUNCT>
<SEDOLREGCNTRY position="23" maxlength="2" type="string">the field Sedolregcntrylength more than max length 2.</SEDOLREGCNTRY>
<STRUCTCD position="24" maxlength="10" type="string">the field StructCDlength more than max length 10.</STRUCTCD>
<EXCHGCNTRY position="25" maxlength="2" type="string">the field ExchgCntrylength more than max length 2.</EXCHGCNTRY>
<EXCHGCD position="26" maxlength="6" type="string">the field ExchgCDlength more than max length 6.</EXCHGCD>
<MIC position="27" maxlength="4" type="string">the field Miclength more than max length 4.</MIC>
<MICSEG position="28" maxlength="4" type="string">the field Micseglength more than max length 4.</MICSEG>
<LOCALCODE position="29" maxlength="50" type="string">the field LocalCodelength more than max length 50.</LOCALCODE>
<LISTSTATUS position="30" maxlength="1" type="string">the field ListStatuslength more than max length 1.</LISTSTATUS>
<LISTDATE position="31" maxlength="" type="datetime">the field Changedlength more than max length</LISTDATE>
<CFI position="32" maxlength="10" type="datetime">the field Changedlength more than max length 10.</CFI>
</EDISecurityMaster593Entity>

2 转换方法为

XElement xel = XElement.Load("..//..//xml//EDICorporateActionRawEntity.xml");
for (int i = 0; i < xel.Elements().Count(); i++)
{
string name = xel.Elements().ElementAt(i).Name.LocalName;
xel.Elements().ElementAt(i).Name = name.ToUpper();
xel.Save("..//..//xml//EDICorporateActionRawEntity.xml");
}

posted @ 2017-06-16 10:21  白羽轻飘  阅读(1031)  评论(0编辑  收藏  举报