473,778 Members | 4,256 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Want to build a small program to change text in xml file, how??

Ron
I need to write a little vb.net app that looks at XML files and
manipulates text in them. Here is what I need to do and I have NO idea
how to do something like this.

here is an example file: also can be found at: http://www.keepitsimplekid.com/xml/Ad00304.xml

<XMD-entity ENTITY_TYPE="Ad " PAGE_NO="3" ID="Ad00304" BOX="450 1030
1229 1429" LANGUAGE="Engli sh" SNP="Ad00304S.j pg" SNP_WIDTH="156"
SNP_HEIGHT="80" >
<Meta NAME="Untitled Ad" DESCRIPTION="" SUBTYPE="" BASE_HREF="ETN/
2007/05/02" SOURCE_TYPE="PD F" PUBLICATION="ET N" SECTION="Up Close"
ISSUE_DATE="02/05/2007" WORDCNT="140" RELEASE_NO="05-02_Complete"
PAGE_ID="sectio n1page3" PAGE_TYPE="Sing le" PAGE_WIDTH="515 "
PAGE_HEIGHT="91 9" DEFAULT_IMG_EXT ="png"
PDF_DESTINATION _MAPPED="OLV0_E ntity_0003_0001 " IMAGES_RESOLUTI ON="100"
XMD_VER="2.6.20 9" PAGE_LABEL="3A"/>
<Link SOURCE="05-02_Complete.pdf " FIRST_ID="Ar003 00" LAST_ID="Pc0030 6"
NEXT_ID="Ad0030 5" PREV_ID="Ad0030 3" TOC_ID="C:/Olive/Repository/ETN/
2007/05/02/TOC.xml"/>
−
<Application_Da ta AD_NUMBER="1" PUB_DATE="1" ETS_ADVERTISER= "1"
CATEGORY="1" AD_WIDTH="1" AD_HEIGHT="1" PAGE_NUMBER="1"
SECTION_NAME="1 " SECTION_PAGE_NU MBER="1" PDF_NAME="1" AD_X="1"
AD_Y="1" WEBSITE="1" EMAIL="1" UPSOLD="1">
−
<Application_In fo AI_TYPE="AD_NUM BER">
<Ai_Item NAME="1515578"/>
</Application_Inf o>
−
<Application_In fo AI_TYPE="PUB_DA TE">
<Ai_Item NAME="05/02/07"/>
</Application_Inf o>
−
<Application_In fo AI_TYPE="ETS_AD VERTISER">
<Ai_Item NAME="LEAF GUARD OF LAKE ERIE"/>
</Application_Inf o>

I have Bolded what I am working with. At the top of the xml where it
says Untitled Ad I want to replace that text with whatever is in the
NAME of the ETS Advertiser, in this case LEAF GUARD OF ERIE

And I want to make the change and save the changes. I then want to be
able to loop through all .xml files in the directory and do this text
swap. Not all xml files will have the same advertiser name, they all
have different ones.

How would I build a program to do this?

May 12 '07 #1
1 1234
On May 12, 6:42Â*pm, Ron <pts4...@yahoo. comwrote:
I need to write a little vb.net app that looks at XML files and
manipulates text in them. Here is what I need to do and I have NO idea
how to do something like this.

here is an example file: also can be found at:http://www.keepitsimplekid.com/xml/Ad00304.xml

<XMD-entity ENTITY_TYPE="Ad " PAGE_NO="3" ID="Ad00304" BOX="450 1030
1229 1429" LANGUAGE="Engli sh" SNP="Ad00304S.j pg" SNP_WIDTH="156"
SNP_HEIGHT="80" >
<Meta NAME="Untitled Ad" DESCRIPTION="" SUBTYPE="" BASE_HREF="ETN/
2007/05/02" SOURCE_TYPE="PD F" PUBLICATION="ET N" SECTION="Up Close"
ISSUE_DATE="02/05/2007" WORDCNT="140" RELEASE_NO="05-02_Complete"
PAGE_ID="sectio n1page3" PAGE_TYPE="Sing le" PAGE_WIDTH="515 "
PAGE_HEIGHT="91 9" DEFAULT_IMG_EXT ="png"
PDF_DESTINATION _MAPPED="OLV0_E ntity_0003_0001 " IMAGES_RESOLUTI ON="100"
XMD_VER="2.6.20 9" PAGE_LABEL="3A"/>
<Link SOURCE="05-02_Complete.pdf " FIRST_ID="Ar003 00" LAST_ID="Pc0030 6"
NEXT_ID="Ad0030 5" PREV_ID="Ad0030 3" TOC_ID="C:/Olive/Repository/ETN/
2007/05/02/TOC.xml"/>
−
<Application_Da ta AD_NUMBER="1" PUB_DATE="1" ETS_ADVERTISER= "1"
CATEGORY="1" AD_WIDTH="1" AD_HEIGHT="1" PAGE_NUMBER="1"
SECTION_NAME="1 " SECTION_PAGE_NU MBER="1" PDF_NAME="1" AD_X="1"
AD_Y="1" WEBSITE="1" EMAIL="1" UPSOLD="1">
−
<Application_In fo AI_TYPE="AD_NUM BER">
<Ai_Item NAME="1515578"/>
</Application_Inf o>
−
<Application_In fo AI_TYPE="PUB_DA TE">
<Ai_Item NAME="05/02/07"/>
</Application_Inf o>
−
<Application_In fo AI_TYPE="ETS_AD VERTISER">
<Ai_Item NAME="LEAF GUARD OF LAKE ERIE"/>
</Application_Inf o>

I have Bolded what I am working with. At the top of the xml where it
says Untitled Ad I want to replace that text with whatever is in the
NAME of the ETS Advertiser, in this case LEAF GUARD OF ERIE

And I want to make the change and save the changes. I then want to be
able to loop through all .xml files in the directory and do this text
swap. Â*Not all xml files will have the same advertiser name, they all
have different ones.

How would I build a program to do this?
If the XML is properly formatted you can use the ablities of the
System.XML namespace. You could load everything into a XMLDocument
and iterate through the nodes using XPATH queries. Once you've
established that with one file, it would be simple to write a loop
that opens a directory, loads each file as an XMLDocument and iterates
through the nodes making the proper changes.

http://support.microsoft.com/default.aspx/kb/318499

http://samples.gotdotnet.com/quickst...entXPath..aspx

That should get you started, just reply with more questions as they
come up and someone can help lead you in the right direction.

May 12 '07 #2

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

Similar topics

3
3005
by: Chris Cioffi | last post by:
I started writing this list because I wanted to have definite points to base a comparison on and as the starting point of writing something myself. After looking around, I think it would be a waste of time to start writing yet another IDE and so am now thinking in terms of new features/plug-ins for existing systems. Right now I mostly use Komodo Personal and it's pretty close to being what I want. They don't currently support plug-ins,...
11
2140
by: Michael B. | last post by:
I'm still learning C so I've written a simple app which lets you make a contact list (stored as a linked list of structs), write it to a file, and read it back. It works fine, but I notice in my loading procedure there's a point or two where I'll malloc a struct which I then don't need, and dispose of it; I was wondering if there was some way I could optimize this kludge out of existence: void loadContacts () { int fd, bytesread; if (...
3
1911
by: Jerry Boone | last post by:
I have a development unit running XP Pro and I cannot get it to build a web project without restarting IIS. There errors in the task list are.... ! Could not copy temporary files to the output directory ! The file'bin\project1.dll' cannot be copied to the run directory. The process cannot access the file because it is being used by another process. ! The file'bin\project1.pdb' cannot be copied to the run directory. The process...
182
7559
by: Jim Hubbard | last post by:
http://www.eweek.com/article2/0,1759,1774642,00.asp
3
4266
by: prabhupr | last post by:
Hi Folks Not sure if this is the right group, if not please re-direct me to the right one. Here is my question =============== When I compile my ASP.NET WEB project from VS 2005 (.NET Framework 2.0) IDE, it works fine, but if I use NANT (Build Automation) it gives me an error as follows:
1
2183
by: dasilva109 | last post by:
Hi guys I am new to C++ and need urgent help with this part of my code for a uni coursework I have to submit by Thursday //ClientData.h #ifndef CLIENTDATA_H #define CLIENTDATA_H #include <string>
14
2295
by: Professor Yonce | last post by:
I have made form for E-Mail. I have entered code but the Import system does not work. It has squiggly line underneath it showing it is not communicating. It Will not build. Public Class Form3Bio1 System.Net.Mail.SmtpClient Imports System.Net.Mail ' This line before ' does not work. I have the rest of code to try if and when I am able to get System working. ' I XXX out certain entrys below just for this publication.
25
2812
by: pereges | last post by:
Hello, I'm trying to build a database driven website for a library management system. The database is stored on a remote server which all of my team mates can access. I've installed MySQL, PHP and Apache on my machine. I'm a beginner and I really don't understand how to proceed. My biggest problem is how to connect to the database on remote mysql server ? Does php allow this kind of thing ? I'm interested in a web interface on my machine...
0
9465
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10127
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10068
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9923
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8954
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7474
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4031
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3627
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.