Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

C#.net XML change/add/remove certain xml

Posted on 2010-08-31
9
499 Views
Last Modified: 2013-12-17
I am having a heck of a time understanding how to manipulate xml entries.

basically what i have created is a test directory of xml files

these are for media center movies and im trying to create a genre consolidation program where i can either remove or change the xml information for the genres

i have attached my file structure and my code to this project

under btnRun_Click
you will see the loop that is completing searching for the genre matches
under cbAction.Text == "Change" and cbAction.Text == "delete"

for change
1 is for changing the information which i was thinking would be best done by removing the old genres first and then adding in the new genres

also i need to check to make sure the same genre isnt listed multiple times if it is to only leave 1 instance of it

for delete

this should only delete out the matches in the list

i have attached the whole project but since experts-exchange eliminates some file extentions here is a list of the ones that will need renamed once downloaded

GenreFixer_2/GenreFixer/GenreFixer.csproj.user.txt
change to
GenreFixer_2/GenreFixer/GenreFixer.csproj.user

GenreFixer_2/GenreFixer/obj/x86/Debug/DesignTimeResolveAssemblyReferences.cache.txt
change to
GenreFixer_2/GenreFixer/obj/x86/Debug/DesignTimeResolveAssemblyReferences.cache


GenreFixer_2/GenreFixer/obj/x86/Debug
DesignTimeResolveAssemblyReferencesInput.cache.txt
change to
GenreFixer_2/GenreFixer/obj/x86/Debug
DesignTimeResolveAssemblyReferencesInput.cache

GenreFixer_2/GenreFixer/obj/x86/Debug/GenerateResource.read.1.tlog.txt
change to
GenreFixer_2/GenreFixer/obj/x86/Debug/GenerateResource.read.1.tlog

GenreFixer_2/GenreFixer/obj/x86/Debug/GenerateResource.write.1.tlog.txt
change to
GenreFixer_2/GenreFixer/obj/x86/Debug/GenerateResource.write.1.tlog

GenreFixer_2/GenreFixer/obj/x86/Debug/GenreFixer.frmGenreFixer.resources.txt
change to
GenreFixer_2/GenreFixer/obj/x86/Debug/GenreFixer.frmGenreFixer.resources

GenreFixer_2/GenreFixer/obj/x86/Debug/GenreFixer.Properties.Resources.resources.txt
change to
GenreFixer_2/GenreFixer/obj/x86/Debug/GenreFixer.Properties.Resources.resources

GenreFixer_2/GenreFixer/Properties/Settings.settings.txt
change to
GenreFixer_2/GenreFixer/Properties/Settings.settings

GenreFixer_2/GenreFixer.suo.txt
change to
GenreFixer_2/GenreFixer.suo

project is in vs2010

   GenreFixer.exe test.zip GenreFixer-2.zip
0
Comment
Question by:shawnmstout
  • 6
  • 3
9 Comments
 
LVL 27

Expert Comment

by:nmarun
ID: 33565779
I think more useful attachment would have been the xml file itself that you're planning to modify/delete entries from. Just put the xml file (at least a part of it) and tell us what needs to happen in each of the scenarios.

Arun
0
 
LVL 3

Author Comment

by:shawnmstout
ID: 33566097
thats in test.zip file which is attached, i take it you havent looked
0
 
LVL 27

Expert Comment

by:nmarun
ID: 33566431
Don't you think this is too much work for both you and me? I mean, you took all the pain to rename each and every file and now I'll have to fish out this class that has the button click event that you're talking about. That's the reason why I suggested you to simplify your question. Post the xml, post your logic and tell what it is that you're trying to do and how far you've gone with it.

Please don't get me wrong. I'm very much willing to help you, but all I'm asking you is to ask a specific question that you have.

Arun
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 3

Author Comment

by:shawnmstout
ID: 33571337
its only 10 files to rename, its not like i didnt supply you with everything, but if its too much i understand, i can wait for someone else to help, i appreciate your time
0
 
LVL 3

Author Comment

by:shawnmstout
ID: 33572677
figured out where im getting stuck at, its at the nodes

here is an example

<Title>
    <Genres>
        <Genre>Whatever</Genre>
    </Genres>
</Title>

im trying to add and remove from the <Genre> tag
0
 
LVL 3

Author Comment

by:shawnmstout
ID: 33572796
nevermind i figured it out on my own
0
 
LVL 3

Author Comment

by:shawnmstout
ID: 33572800
please close this out
0
 
LVL 3

Accepted Solution

by:
shawnmstout earned 0 total points
ID: 33572807
xmlLoaded.Element("Title").Element("Genres").Add(new XElement("Genre", newGenre.ToString()));   adds it in successfully
0
 
LVL 27

Expert Comment

by:nmarun
ID: 33573761
Glad you were able to resolve this.

Arun
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question