help with this XML attribute thing

Results 1 to 2 of 2

Thread: help with this XML attribute thing

  1. #1
    Join Date
    Dec 1969

    Default help with this XML attribute thing

    Folks,<BR> I cannot seem to figure this out. I am sure this is simple, but I just can&#039;t get it. I am trying to edit an XML document. I need to add an attribute to certain elements. But I just cannot find the command. Can anyone help me out. This is what I have that does not work<BR><BR> Public Function EditXML(ByVal sFileName As String, ByVal sRequestItem As String)<BR> Dim oTR As New XmlTextReader(sFileName)<BR> Dim oTW As New XmlTextWriter(sFileName, Encoding.ASCII)<BR> Dim item As String<BR><BR> If oTR.IsEmptyElement = False Then<BR> If oTR.NodeType = XmlNodeType.Element Then<BR> If oTR.Name = sRequestItem Then<BR> oTW.WriteAttributeString("include", "yes")<BR> End If<BR> End If<BR> End If<BR> oTR.Close()<BR> oTW.Close()<BR> oTR = Nothing<BR> oTW = Nothing<BR><BR> End Function<BR><BR>Thanks alot

  2. #2

    Default RE: help with this XML attribute thing

    Try<BR> oTR.AddAttribute(...)<BR>instead of<BR> oTW.WriteAttributeString("include", "yes") <BR><BR>You will also need to write everything else from the reader into the writer.<BR><BR>It might be easier to get a feel for xml if you use xmlDocument instead of the more optimized readers and writers<BR>

Posting Permissions

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