Results 1 to 4 of 4

Thread: xml without indentation?

  1. #1
    muminraif is offline VB.NET Forum Newbie
    .NET Framework
    .NET 2.0
    Join Date
    Jun 2010
    Posts
    2
    Reputation
    0

    xml without indentation?

    Hello,

    I am trying to write a code in VB that writes something to an xml file. However, when I open the xml file by NotePad, etc. member elements start from 2 space characters inside. I tried to do all of the elements root element but it is not allowed I guess. So, do we have a solution to see the xml file like this:

    <?xml version="1.0" ?>
    <Map xmlns="http://www.semi.org" WaferId="" FormatRevision="SEMI G85-1101">
    <Device BinType="HexaDecimal" WaferSize="300">
    <ReferenceDevice ReferenceDeviceX="4" ReferenceDeviceY="4"/>
    <Bin Bins="1" />
    <Bin BinCode="0E" BinQuality="Pass" BinDescription="" BinCount="54" />
    <Data MapName="d1.xml" CreateDate="2010062395044">
    <Row><![CDATA[FFFFFFFF0EFFFFFFFF]]></Row>
    <Row><![CDATA[FFFF0E0E0E0E0EFFFF]]></Row>
    <Row><![CDATA[FF0E0E0E0E0E0E0EFF]]></Row>
    <Row><![CDATA[0E0E0E0E0E0E0E0EFF]]></Row>
    <Row><![CDATA[0E0E0E0E0E0E0E0E0E]]></Row>
    <Row><![CDATA[0E0E0E0E0E0E0E0EFF]]></Row>
    <Row><![CDATA[FF0E0E0E0E0E0E0EFF]]></Row>
    <Row><![CDATA[FF0E0E0E0E0E0EFFFF]]></Row>
    <Row><![CDATA[FFFFFF0E0E0EFFFFFF]]></Row>
    </Data>
    </Device>
    </Map>

    Instead of this:

    _<?xml version="1.0" ?>
    _<Map xmlns="http://www.semi.org" WaferId="" FormatRevision="SEMI G85-1101">
    _spaces <Device BinType="HexaDecimal" WaferSize="300">
    _spaces <ReferenceDevice ReferenceDeviceX="4" ReferenceDeviceY="4"/>
    _spaces <Bin Bins="1" />
    _spaces <Bin BinCode="0E" BinQuality="Pass" BinDescription="" BinCount="54" />
    _spaces <Data MapName="d1.xml" CreateDate="2010062395044">
    _spaces <Row><![CDATA[FFFFFFFF0EFFFFFFFF]]></Row>
    _spaces <Row><![CDATA[FFFF0E0E0E0E0EFFFF]]></Row>
    _spaces <Row><![CDATA[FF0E0E0E0E0E0E0EFF]]></Row>
    _spaces <Row><![CDATA[0E0E0E0E0E0E0E0EFF]]></Row>
    _spaces <Row><![CDATA[0E0E0E0E0E0E0E0E0E]]></Row>
    _spaces <Row><![CDATA[0E0E0E0E0E0E0E0EFF]]></Row>
    _spaces <Row><![CDATA[FF0E0E0E0E0E0E0EFF]]></Row>
    _spaces <Row><![CDATA[FF0E0E0E0E0E0EFFFF]]></Row>
    _spaces <Row><![CDATA[FFFFFF0E0E0EFFFFFF]]></Row>
    _spaces </Data>
    _spaces </Device>
    _</Map>

    ps: there are 2 character spaces where I wrote "spaces" in the code, they cant be shown normally because mailbox automatically aligns them to the left
    Last edited by muminraif; 06-24-2010 at 4:26 AM.

  2. #2
    JohnH's Avatar
    JohnH is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    14,200
    Reputation
    2369
    XmlWriterSettings Class (System.Xml) as you can see in example you can set Indent=False

  3. #3
    muminraif is offline VB.NET Forum Newbie
    .NET Framework
    .NET 2.0
    Join Date
    Jun 2010
    Posts
    2
    Reputation
    0

    thanks

    Thank you very much, but I have to ask another thing to try that solution in my code. I have created my elements with XmlElements not with XmlWriter. Then how can I apply the settings that I have done by using that code to my document.

  4. #4
    JohnH's Avatar
    JohnH is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    14,200
    Reputation
    2369
    For XmlDocument.Save method you can use this version XmlDocument.Save Method (XmlWriter) (System.Xml)
    So you create the writer with custom settings and output the document through this.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Harvest time tracking