1

I am trying to replace a found attribute with a new value, but can not seem to get it....

XML Example

<department sysid="1" name="a" minAmt="0.00" maxAmt="0.00" isAllowFS="0" isNegative="0" isFuel="0" isAllowFQ="0" isAllowSD="0" isBL1="0" isBL2="0" isMoneyOrder="0">
  <category sysid="0" />

Code

            For Each node In xmldoc.SelectNodes("//department")
                'For Each node In nodeDepartment
                Dim a = node.getAttribute("isFuel").ToString
                If a = 0 Then
                    node.ChildNodes.Item(1).Attributes.getNamedItem("sysid").Value = "400"
                    Dim sName As String = node.getAttribute("name").ToString 'I get the value here
                    If Trim(sName) = "" Then
                        node.Attribute("name") = "A" 'I Error on this line 
                    End If
                End If
                lCount += 1
            Next

1 Answer 1

1

You need to use the SetAttribute Method instead of GetAttribute.

If Trim(sName) = "" Then 

    node.SetAttribute("name", "A") 

End If
Sign up to request clarification or add additional context in comments.

2 Comments

I tried something like that, but had the syntax wrong. Thank You!
You're welcome. If this resolves your question, please do not forget to mark it as the accepted answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.