Editing XML Document

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ameen.abdullah@gmail.com

    #1

    Editing XML Document

    Hi Guys,

    I hve an application which uses xml file to store data.. Now i need to
    edit/delete particular node (inner xml + attributes) in that xml file.
    How can i do that?

    Thanks in advance..

  • zacks@construction-imaging.com

    #2
    Re: Editing XML Document


    ameen.abdullah@ gmail.com wrote:
    Hi Guys,
    >
    I hve an application which uses xml file to store data.. Now i need to
    edit/delete particular node (inner xml + attributes) in that xml file.
    How can i do that?
    >
    Thanks in advance..
    It's just a text file. Open it in your favorite text editor.

    Comment

    • Cor Ligthert [MVP]

      #3
      Re: Editing XML Document

      Ameen,

      An XML file says not so much, XML is a set of keywords used to by instance
      define the elements and attributes in a document.

      What kind of XML document do you have, the most simple question is, does it
      contain only elements, than it is probably a dataset, or does it contains as
      well attributes, than it is probably a document.

      Cor

      <ameen.abdullah @gmail.comschre ef in bericht
      news:1153761108 .194993.311840@ m73g2000cwd.goo glegroups.com.. .
      Hi Guys,
      >
      I hve an application which uses xml file to store data.. Now i need to
      edit/delete particular node (inner xml + attributes) in that xml file.
      How can i do that?
      >
      Thanks in advance..
      >

      Comment

      • ameen.abdullah@gmail.com

        #4
        Re: Editing XML Document

        Heres a sample of xml doc which i m using:

        <tables>
        <table name="table1">
        <columns>
        <column name="col1" datatype="varch ar" length="20" />
        <column name="col2" datatype="int" length="2" />
        <column name="col3" datatype="datet ime" length="8" />
        </columns>
        </table>
        </tables>

        Now, what i need is to know how can i add a new node in columns node or
        tables node, and how can i change any attribute, for eg: i need to
        rename table1 to table2 or change the datatype of col1 to int through
        vb.net.


        Cor Ligthert [MVP] wrote:
        Ameen,
        >
        An XML file says not so much, XML is a set of keywords used to by instance
        define the elements and attributes in a document.
        >
        What kind of XML document do you have, the most simple question is, does it
        contain only elements, than it is probably a dataset, or does it contains as
        well attributes, than it is probably a document.
        >
        Cor
        >
        <ameen.abdullah @gmail.comschre ef in bericht
        news:1153761108 .194993.311840@ m73g2000cwd.goo glegroups.com.. .
        Hi Guys,

        I hve an application which uses xml file to store data.. Now i need to
        edit/delete particular node (inner xml + attributes) in that xml file.
        How can i do that?

        Thanks in advance..

        Comment

        • Cor Ligthert [MVP]

          #5
          Re: Editing XML Document

          Ameen,

          This is simple, this is a datatable therefore it is just read it using
          ds.readxml and then

          ds.tables("tabl e1").columns.ad d("col4",gettyp e(system.int32) )

          I don't think that you can change the type varchar to int32 in one time, you
          can try it, than it can be
          dt.Columns("col 1").DataType = GetType(System. Int32)

          But I don't think that will go, so you can use
          \\\
          ds.tables("tabe l1")columns.add ("colDummy",get type(system.int 32))
          for each dr as datarow in ds.tables("tabl e1")
          dr("colDummy") = Cint(dr("col1") )
          next
          dt.Columns.("co l1").remove
          dt.Columns("co1 Dummy").ColumnN ame = "col1"
          ////

          And than write it again with WriteXML(and add the schema than to that in the
          secondparameter )

          This above is not really tested but typed in this message, therefore there
          can be typos or whatever.

          I hope this helps,

          Cor

          <ameen.abdullah @gmail.comschre ef in bericht
          news:1153820637 .698897.130970@ m79g2000cwm.goo glegroups.com.. .
          Heres a sample of xml doc which i m using:
          >
          <tables>
          <table name="table1">
          <columns>
          <column name="col1" datatype="varch ar" length="20" />
          <column name="col2" datatype="int" length="2" />
          <column name="col3" datatype="datet ime" length="8" />
          </columns>
          </table>
          </tables>
          >
          Now, what i need is to know how can i add a new node in columns node or
          tables node, and how can i change any attribute, for eg: i need to
          rename table1 to table2 or change the datatype of col1 to int through
          vb.net.
          >
          >
          Cor Ligthert [MVP] wrote:
          >Ameen,
          >>
          >An XML file says not so much, XML is a set of keywords used to by
          >instance
          >define the elements and attributes in a document.
          >>
          >What kind of XML document do you have, the most simple question is, does
          >it
          >contain only elements, than it is probably a dataset, or does it contains
          >as
          >well attributes, than it is probably a document.
          >>
          >Cor
          >>
          ><ameen.abdulla h@gmail.comschr eef in bericht
          >news:115376110 8.194993.311840 @m73g2000cwd.go oglegroups.com. ..
          Hi Guys,
          >
          I hve an application which uses xml file to store data.. Now i need to
          edit/delete particular node (inner xml + attributes) in that xml file.
          How can i do that?
          >
          Thanks in advance..
          >
          >

          Comment

          Working...