K
Kasp
Hi,
Here is my problem....
I have an XML with many "HierarchyMembe" node. I have to check the
attributes called "PageKey" & "MemberName" for single quotes and replace
their occurance with 2 single quotes. Here is my VB code that uses MSXML:
Set hierarchyMemberList = xmlDocument.selectNodes("//HierarchyMember")
For Each hierarchyMemberNode In hierarchyMemberList
strPageKey =
hierarchyMemberNode.Attributes.getNamedItem("PageKey").nodeValue
strMembername =
hierarchyMemberNode.Attributes.getNamedItem("MemberName").nodeValue
If strPageKey = "" Then
strPageKey = "null"
Else
strPageKey = Replace(strPageKey, "'", "''")
End If
If strMembername = "" Then
strMembername = "null"
Else
strMembername = Replace(strMembername, "'", "''")
End If
'return safe attributes back to xml
hierarchyMemberNode.Attributes.getNamedItem("PageKey").nodeValue =
strPageKey
hierarchyMemberNode.Attributes.getNamedItem("MemberName").nodeValue
= strMembername
Next
xmlDocument.save("test.xml")
My question is how can I change the attribute of this child. The last 2
lines in the loop (getNamedItem = newValue) doesn't seem to work.
Why is this happening and how can I change the existing attribute value to
hold a new value?
TIA.
Kasp.
Here is my problem....
I have an XML with many "HierarchyMembe" node. I have to check the
attributes called "PageKey" & "MemberName" for single quotes and replace
their occurance with 2 single quotes. Here is my VB code that uses MSXML:
Set hierarchyMemberList = xmlDocument.selectNodes("//HierarchyMember")
For Each hierarchyMemberNode In hierarchyMemberList
strPageKey =
hierarchyMemberNode.Attributes.getNamedItem("PageKey").nodeValue
strMembername =
hierarchyMemberNode.Attributes.getNamedItem("MemberName").nodeValue
If strPageKey = "" Then
strPageKey = "null"
Else
strPageKey = Replace(strPageKey, "'", "''")
End If
If strMembername = "" Then
strMembername = "null"
Else
strMembername = Replace(strMembername, "'", "''")
End If
'return safe attributes back to xml
hierarchyMemberNode.Attributes.getNamedItem("PageKey").nodeValue =
strPageKey
hierarchyMemberNode.Attributes.getNamedItem("MemberName").nodeValue
= strMembername
Next
xmlDocument.save("test.xml")
My question is how can I change the attribute of this child. The last 2
lines in the loop (getNamedItem = newValue) doesn't seem to work.
Why is this happening and how can I change the existing attribute value to
hold a new value?
TIA.
Kasp.