MISdad
Technical User
- May 5, 2004
- 34
I need to be able to save uploaded file names to a specific XML Element. Here's where I am...
My XML File
I can currently insert images but they are all going under the first album. I need to be able to specify which album the new images get put into based on a text box entry.
I have the following C# code which adds the new image...
What I need to know is how to specify the correct albumname attribute (ie. PhotoAlbum1 or PhotoAlbum2) along with the album Element that newElement is being added to.
My XML File
Code:
<?xml version="1.0" encoding="utf-8"?>
<photoalbum>
<album albumname="PhotoAlbum1" id="1">
<image id="1" imagename="pic1.jpg" />
<image id="2" imagename="pic2.jpg" />
<image id="3" imagename="pic3.jpg" />
</album>
<album albumname="PhotoAlbum2" id="2">
<image id="1" imagename="pic1.jpg" />
<image id="2" imagename="pic2.jpg" />
<image id="3" imagename="pic3.jpg" />
</album>
</photoalbum>
I can currently insert images but they are all going under the first album. I need to be able to specify which album the new images get put into based on a text box entry.
I have the following C# code which adds the new image...
Code:
Xelement newElement =
new XElement("image",
new XAttribute("imagename", uploadedFileName.ToString()));
parentElement.Element("album").Add(newElement);
rootElement.Save(filename);
What I need to know is how to specify the correct albumname attribute (ie. PhotoAlbum1 or PhotoAlbum2) along with the album Element that newElement is being added to.