473,406 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Alter the attributes content

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("PageK ey").nodeValue
strMembername =
hierarchyMemberNode.Attributes.getNamedItem("Membe rName").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("PageK ey").nodeValue =
strPageKey
hierarchyMemberNode.Attributes.getNamedItem("Membe rName").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.
--
"Accept that some days you are the pigeon and some days the statue."
"A pat on the back is only a few inches from a kick in the butt." - Dilbert.
Jul 20 '05 #1
1 1634
"Kasp" <ka*************@epatra.com> wrote in message
news:bm**********@newsreader.mailgate.org
[... VB Example snipped ...]

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.


Work with a DomElement object (not a DOMNode) and use it's setAttribute
method.

Martin
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Richard Hollenbeck | last post by:
I made a table this way: mysql>create table tblCourses (courseCode char(30) primary key, courseDescription char(50)); Now I realize that I forgot to enforce that both fields will not be null....
3
by: Pat | last post by:
Hi all, In contruction of DTD for a scenario, what are the rules/guildelines to determine if certain piece of information should be stated as child element or an attribute? I read some...
12
by: Oberon | last post by:
I have a large HTML document. It has hundreds of <span>s which have no attributes so these <span>s are redundant. How can I remove these tags automatically? The document also has <span>s with...
8
by: nicolas.sanguinetti | last post by:
Hi, I want to add custom attributes to my xhtml documents to use with my DOM scripts. For example, I want to have some tags -say, the <h1>- have an attribute and a . The thing is that I also...
5
by: Steven Berkovitz | last post by:
Hi there, I am having a problem where if i add an attribute to a control at runtime the rendered attribute is HTML encoded. For example, on a textbox: textBox.Attributes = "if(x && y)...
2
by: Alan Mailer | last post by:
I'm sorry if this one has been asked and answered a million times: Is it possible to have a VB6 app alter the name of an *existing* field in Access 2002 database? To be clear, I'm not talking...
3
by: apiringmvp | last post by:
All, So I am creating a function that gets a short blurb of html from a blog. I would like to retain all html formating and images. The code below works well, with the exception of one issue....
11
by: raylopez99 | last post by:
Keep in mind this is my first compiled SQL program Stored Procedure (SP), copied from a book by Frasier Visual C++.NET in Visual Studio 2005 (Chap12). So far, so theory, except for one bug...
1
by: Chota | last post by:
Hi, I am currently working with a database, and I am being asked to delete a row from this table. let's call it department with the attributes (dcode CHAR(20), dname CHAR(20)). Now i have to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.