xml Serialize get rid namespce or xsd

แนะนำ สอบถาม ภาษา C สำหรับผู้เริ่มต้น ภาษา Java ภาษา Python

Moderators: mindphp, ผู้ดูแลกระดาน

User avatar
jataz2
PHP Super Member
PHP Super Member
Posts: 240
Joined: 22/02/2011 11:48 am

xml Serialize get rid namespce or xsd

Post by jataz2 » 28/02/2019 5:01 pm

Code: Select all

using (StringWriter textWriter = new StringWriter())
                {
                    slizer.Serialize(textWriter, DS_FCR);
                    string getridXSD = textWriter.ToString().Replace("xmlns:xsd=","");
                    getridXSD = getridXSD.Replace("\"http://www.w3.org/2001/XMLSchema\"", "");

                    using (StreamWriter writer = new StreamWriter("d:\test.xml", true, Encoding.UTF8))
                    {
                        writer.Write(getridXSD);
                       
                        writer.Flush();
                        writer.Dispose();
                        writer.Close();
                    }
                }
output=>

Code: Select all

<?xml version="1.0" encoding="utf-16"?>
<DS_FCR xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  name="Foreign Exchange Counter Rates" type="Fixed CL no sub-repeating" schemaVersion="TCB 3.0">
  <CommonHeader>
    <OrganizationId>069</OrganizationId>
    <DataSetDate>2019-02-28</DataSetDate>
  </CommonHeader>
  <DS_FCR_Header />
  <DS_FCR_Content>
    <ContentRecordGroup>
      <RoundNumber>14</RoundNumber>
      <CurrencyID_USD name="ดอลลาร์ สหรัฐอเมริกา">
        <SightBillRate>0</SightBillRate>
        <TtRate>31.09</TtRate>
        <SellingRate>31.344</SellingRate>
      </CurrencyID_USD>
    </ContentRecordGroup>
  </DS_FCR_Content>
</DS_FCR>
Last edited by jataz2 on 01/07/2019 4:29 pm, edited 1 time in total.

vidya31
PHP Newbie
PHP Newbie
Posts: 2
Joined: 01/03/2019 5:41 pm

Re: xml Serialize get rid namespce or xsd

Post by vidya31 » 04/03/2019 3:32 pm

Thanks for the coding ..!!

Post Reply
  • Similar Topics
    Replies
    Views
    Last post

Return to “Programming - C/C++ & java & Python”

Who is online

Users browsing this forum: Bing [Bot] and 2 guests