473,386 Members | 1,867 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,386 software developers and data experts.

code almost working except... ? help ??

Ron
This code is almost doing what I want it to do, here is the code:
private void btnConvert_Click(object sender, EventArgs e)
{
// Get a directory
string path = @"c:\WAMP\";

foreach (string fileName in Directory.GetFiles(path,
"*.xml"))
{
XmlDocument xdoc = new XmlDocument();

xdoc.Load(fileName);

((XmlAttribute)xdoc.SelectSingleNode("/XMD-entity/Meta/
@NAME")).Value = "new value";

((XmlAttribute)xdoc.SelectSingleNode("/XMD-entity/
Application_Data/Application_Info[@AI_TYPE='ETS_ADVERTISER']/Ai_Item/
@NAME")).Value = "new value";

xdoc.Save(fileName);
}
}

What this code does is it reads all .xml files in a directory, XML
files like the 2 examples here: http://www.keepitsimplekid.com/xml
it then takes and Replaces Untitled Ad twoards the top of the xml doc
with the text New Value. It also replaces the ETS ADVERTISER name,
for example REGIONAL CANCER CENTER, or LEAF GUARD OF LAKE ERIE with
the text new value.

Here is what I want to do. I will delete the line of code that
replaces the ETS ADVERTISER name with New Value, I want to keep the
line of code near the top that replaces the words Untitled Ad.
Instead of replacing Untitled Ad with new value, I want to replace it
with the value that is ETS ADVERTISER name, so Untitled Ad would be
replaced with LEAF GUARD OF LAKE ERE, or, REGINAL CANCER CENTER

How do I replace / fix this line of code to do that?
((XmlAttribute)xdoc.SelectSingleNode("/XMD-entity/Meta/@NAME")).Value
= "new value";

so I don't want it to = the text new value, I want it to = whatever
the ETS ADVERTISER name actually is.

May 17 '07 #1
1 1344
Hi Ron,

I'm not entirely sure I grasped your problem. It looks to me like you want to replace "new value" with the AI_ITEM Name value from the ETS_ADVERTISER node. If so, just rearrange the two lines:
string value = ((XmlAttribute)xdoc.SelectSingleNode("/XMD-entity/Application_Data/Application_Info[@AI_TYPE='ETS_ADVERTISER']/Ai_Item/@NAME")).Value;

((XmlAttribute)xdoc.SelectSingleNode("/XMD-entity/Meta/@NAME")).Value =value;
If this is not what you want, please feel free to correct me.

--
Happy coding!
Morten Wennevik [C# MVP]
May 17 '07 #2

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

Similar topics

9
by: bigoxygen | last post by:
Hi. I'm using a 3 tier FrontController Design for my web application right now. The problem is that I'm finding to have to duplicate a lot of code for similar functions; for example, listing...
3
by: Bart Nessux | last post by:
This is almost working. I've read up on queues and threads and I've learned a lot, still not enough to fully understand what I'm doing though, but I'm getting there. Much of this script was copied...
242
by: James Cameron | last post by:
Hi I'm developing a program and the client is worried about future reuse of the code. Say 5, 10, 15 years down the road. This will be a major factor in selecting the development language. Any...
9
by: Tzu-Chien Chiu | last post by:
Hi, "What methods do you ever use to optimize the programs?" We're developing a graphics chip emulator in C++, but it's very slow for big scenes. Even though this is a cross-platform software,...
109
by: Andrew Thompson | last post by:
It seems most people get there JS off web sites, which is entirely logical. But it is also a great pity since most of that code is of such poor quality. I was looking through the JS FAQ for any...
7
by: David. E. Goble | last post by:
Hi all; I have the following files; index.html, sigsheader.js, sigsboby.js, smilesbody.js and smiles.js. The sourse is below. The page displays two manual slide shows... Each slideshow has a set...
17
by: tshad | last post by:
Many (if not most) have said that code-behind is best if working in teams - which does seem logical. How do you deal with the flow of the work? I have someone who is good at designing, but...
232
by: robert maas, see http://tinyurl.com/uh3t | last post by:
I'm working on examples of programming in several languages, all (except PHP) running under CGI so that I can show both the source files and the actually running of the examples online. The first...
66
by: John | last post by:
Hi What are the advantages actually achieved of managed code? I am not talking of theory but in reality. Thanks Regards
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.