Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Edit an XML file (Vb.NET)

Options
  • 01-10-2008 12:48pm
    #1
    Registered Users Posts: 7,680 ✭✭✭


    I have the following XML file which I need to edit
    - <ImportSession DeleteBatchOnError="1">
    - <Batches>
    - <Batch BatchClassName="EmailOutput">
    - <Documents>
    - <Document RequestID="22">
    - <IndexFields>
      <IndexField Name="EmailFrom" Value="hello" /> 
      <IndexField Name="EmailFromAddress" Value="he.llo@hotmail.com" /> 
      <IndexField Name="EmailTo" Value="hello@hotmail.com" /> 
      <IndexField Name="EmailSubject" Value="Test Thursday" /> 
      <IndexField Name="EmailCC" Value="" /> 
      <IndexField Name="EmailDateTime" Value="9/25/2008 2:17:45 PM" /> 
      <IndexField Name="MailboxName" Value="mailbox" /> 
      <IndexField Name="OBJECT_CLASS" Value="Email" /> 
      <IndexField Name="Policy_No" Value="012344" /> 
      <IndexField Name="Claim_No" Value="999999999" /> 
      <IndexField Name="Broker_No" Value="876543" /> 
      </IndexFields>
      </Document>
      </Documents>
      </Batch>
      </Batches>
      </ImportSession>
    
    

    I can retrieve the values using the following
    Dim xmlObj As New Xml.XmlDocument
            Dim m_node As Xml.XmlNode
            Dim m_nodelist As XmlNodeList
            Dim policyNo as string
    
            xmlObj.Load(_file)
    
            m_nodelist = xmlObj.SelectNodes("/ImportSession/Batches/Batch/Documents/Document/IndexFields/IndexField[@Name='Policy_No']")
    
            'Load the document 
            Try
                m_nodelist = xmlObj.SelectNodes("/ImportSession/Batches/Batch/Documents/Document/IndexFields/IndexField[@Name='Policy_No']")
                For Each m_node In m_nodelist
                   policyNo = m_node.Attributes.GetNamedItem("Value").Value = "01PMV0123456"
                Next
    
    

    I need to edit the Policy_No element. Can some direct me in the right direction please.

    I tried doing setnameditem but looking for xml object
    Thanks in advance


Advertisement