#### XML newbie: How to add/replace an attribute

Hi all,

Whenever I need to deal with XML I kind of stumble around in the XML
namespace until I find the class that seems to do what I'm trying to do.
This time around, I've been trying to find a reasonably straightforward way
to do something that should be very simple, and I've gotten to the point
where I need to ask for help.

I have a bunch of files that contain XML looks like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest version="1" exceptions="*.doc">
<file>.\abc.txt</file>
<file>.\def.txt</file>
</manifest>

I need to modify each file, if necessary, so that the <manifest> tag
contains an exceptions attribute with a specific value.  Some files will
already have the required attrtibute.  Some will have the attribute with an
incorrect value, in which case I simply want to throw away the existing
value and replace it with the correct value.  And some will be missing the
attribute entirely, in which case I want to add the attribute.

Can some kind soul provide a code snippet that does this?  Thanks a million!

- Bob


 0
rda1 (14)
5/18/2007 5:05:03 PM
dotnet.xml 7266 articles. 0 followers.

1 Replies
893 Views

Similar Articles

[PageSpeed] 12

Never mind, I figured it out...  I wish the documentation for the
XmlDocument and related classes was better...

"Bob Altman" <rda@nospam.nospam> wrote in message
news:uOblu6WmHHA.4552@TK2MSFTNGP05.phx.gbl...
> Hi all,
>
> Whenever I need to deal with XML I kind of stumble around in the XML
> namespace until I find the class that seems to do what I'm trying to do.
> This time around, I've been trying to find a reasonably straightforward
> way to do something that should be very simple, and I've gotten to the
> point where I need to ask for help.
>
> I have a bunch of files that contain XML looks like this:
>
> <?xml version="1.0" encoding="utf-8"?>
> <manifest version="1" exceptions="*.doc">
>  <file>.\abc.txt</file>
>  <file>.\def.txt</file>
> </manifest>
>
> I need to modify each file, if necessary, so that the <manifest> tag
> contains an exceptions attribute with a specific value.  Some files will
> already have the required attrtibute.  Some will have the attribute with
> an incorrect value, in which case I simply want to throw away the existing
> value and replace it with the correct value.  And some will be missing the
> attribute entirely, in which case I want to add the attribute.
>
> Can some kind soul provide a code snippet that does this?  Thanks a
> million!
>
>  - Bob
>


 0
rda1 (14)
5/18/2007 11:44:59 PM

Similar Artilces:

Form design to add data to 3 tables in "Order Entry" style db
Sorry if this is a duplicate. I thought I posted it yesterday but couldn't find it today... I need help figuring out the best way to design a form for data entry in the "Order Entry" style, adding data to three related tables. For clarity I have eliminated several fields. Here are the three tables, plus the fourth that is a reference table: tblCustomers: CustID (pk), CustName tblOrders: OrderID (pk), OrderDate, CustID (fk) tblOrderProd: OrderProdID (pk), OrderID (fk), ProdID (fk) tblProducts: ProdID (pk), ProdName Each Customer is associated with one or mo...

Add the contents of two sheets together
I am looking for a way to add the content of two sheets or even 1 shee together. I have a large list of part numbers with quantities. Som of the part numbers are repeated. I would like to add the duplicat part number quantities together and have just 1 line with the par number and the total quantity. Does anyone have any insight? Thank -- Message posted from http://www.ExcelForum.com Hi Sounds like a job for a pivot table. See here for an intro: http://www.cpearson.com/excel/pivots.htm -- Andy. "mwiggins367 >" <<mwiggins367.16x77f@excelforum-nospam.com> wrote...

Why can't I use an event sink to add a header entry
The msdn site says the property is read only. Anyone know of a way to do this? ...

I've created a customized LinkedTableManager which allows me to perform most of the LTM functions, within my environment, while using DSN-less connections. I've developed this to be an add-in (or at least I thought I had), but I'm having difficulty with the USysRegInfo table and getting it to actually register as an add-in. I currently have added the mda file as a reference in my main application, and that seems to be working fine. What are the pros and cons of these two methods? Dale -- email address is invalid Please reply to newsgroup only. ...

Newbie Xpath Question #2
Hi everyone, i have a quesiton regarding XML/Xpath i have a XML document that has let say the following structure <cases> <case> <num>1<num> <detective> <name>John</name> <lastname>Smith</lastname> <detective> </case> <case> <num>2<num> <detective> <name>Roger</name> <lastname>Wilco</lastname> <detective> </case> </cases> I want to know, what would be the most "by the ...

Inserted Pictures keep disappearing replaced w/ white box with a r
I have never had this problem in power point before. I opened an old presentation to update it (Professional Edition 2003). Photos I had inserted were gone and replaced with white squares with red Xs. I tried to replace the photos and saved it. When I went to reopen today, the photos are gone again. HELP! Also, when I open the folder and point to the file I want to open, the small "Details" icon still shows my photos as being there, but they're not there; when I try to print, it's the white square with the red x. Thanks for any support anyone can give me! ...

Newbie
This is my situation - the data that I am attempting to chart is a combination of numbers and y/n which are answers to questions about usage: Example: Location: Apple Task To Be Done (Y/N): Y Task Should Be Done(Y/N): Y Quantity Done (#): 12 Quantity Not Done (#): 4 There are 13 locations Each location has 2 resources Ultimately, I am trying to show value added using current resources. However, I am stuck. Can anyone help? Thank you. You have left out more than you've supplied. How are you defining, measuring, and calculating "value"? What parameters do you want ...

After Add Record, Put Cursor in specific Text Box
Hi, I had the wizard set up a button to add record (it puts in the code below in the On Click property of the button). I'd then like to have the focus go to text box [ProjectType]. I don't know how to do that. TIA :) Private Sub cmdAddRecord_Click() On Error GoTo Err_cmdAddRecord_Click DoCmd.GoToRecord , , acNewRec Exit_cmdAddRecord_Click: Exit Sub Err_cmdAddRecord_Click: MsgBox Err.Description Resume Exit_cmdAddRecord_Click End Sub Private Sub cmdAddRecord_Click() On Error GoTo Err_cmdAddRecord_Click If Me.Dirty Then Me.Dirty = False If ...

Hi I have a function called GetXml that returns Xml as expected. I then use: Dim saveFile As New SaveFileDialog and the configure saveFile. Having got the file and the Xml, how can I then write the Xml to the file? Also, how could I load the Xml back in to a string using an OpenFileDialog (openFile) or similar? Regards, Carl Gilbert "Carl Gilbert" <cnl@newsgroup.nospam> wrote in message news:OHk4WC5qEHA.628@TK2MSFTNGP09.phx.gbl... > Having got the file and the Xml, how can I then write the Xml to the file? Dim writer As System.IO.StreamWriter writer = ...

My students need to install and use some of the standard Excel add-ins, but some cannot find the required install disc. Is there a way to do this without the install disc? carbon_noodle - The experience of my students has been limited to Solver and Analysis ToolPak, and , as I recall, you definitely need the Office/Excel installation CD. However, as I recall, you can use any Office/Excel CD, as long as it's for the identical version of Office/Excel that is currently installed on the hard drive. - Mike www.mikemiddleton.com "carbon_noodle" <QuantumKinetics@gmail.com&...

Pressing Tab to add a new record at the end of one record in a for
Back in Access 97 and 2003, I noticed that when you reach the end of a record in a form and press tab, it used to take you to a new record. But, in Access 2007, it's not doing that. Please let me know what I need to check for to enable this function. There's a form property (Cycle) that affects how a <Tab> affects the screen. You can set it to (re-)cycle back through the fields of the record you're on, or move to the next record. Regards Jeff Boyce Microsoft Office/Access MVP "briangw" <briangw@discussions.microsoft.com> wrote in message news:329198...

how do I add information from many worksheets to one main workshee
Hello, Without knowing how your data structure is setup, it's fairly difficult to know what you are dealing with and provide you with a specific answer. But you can use formulas to bring in data from other sheets ... =Sheet1!A1 =Sheet2!A2 =Sheet3!A3 ... etc. HTH -- Regards, Zack Barresse, aka firefytr "sillygurl" <sillygurl@discussions.microsoft.com> wrote in message news:71FD774A-B1B6-42B0-AA3E-D5D18416E13F@microsoft.com... > With Links, In whatever cell in the main sheet you want to start listing the dat type =, then go to the first cell in the work...

XML
I can not locate XML on my Data menu for Excel. I checked to see if it was an add-on but it's not. You don't say which version and edition of Excel you are running. From Excel 2003 help. Note XML features, except for saving files in the XML Spreadsheet format, are available only in Microsoft Office Professional Edition 2003 and Microsoft Office Excel 2003. Excel 2007 has XML support also. Gord Dibben MS Excel MVP On Tue, 24 Jul 2007 10:08:03 -0700, emi <emi@discussions.microsoft.com> wrote: >I can not locate XML on my Data menu for Excel. I checked to see if it wa...

XML Security
I have posted this on ASP security to no avail. I have a web app written in c#. This app dynamically creates an Xsl doc from user defined info in the database. It also creates an instance of another c# class. This object gets passed into the Xsl doc as a parameter, and it is called from within the stylesheet to perform various functions during transformation. This object also uses some gdi32 and other unmanaged code. The I am seeing is that various exceptions (SecurityException, namely) are thrown from the component any time these methods are called. I have tried granting FullTru...

Search and replace problem
Hi, I have an Excel worksheets where in several cell's a symbol was added to mark the cell's "to review". The symbol used was "(*)". I have tried now to delete all the entries with a "search and replace", but Excel interpretes the asterisk as a DOS-symbol and deletes everythng between brackets. Is there a way to avoid that or to let Excel know that I only want to delete the specific characters. TIA Melissa It's because it is a wildcard, you can replace it by preceding it with a tilde ~ which tell Excel to find an asterisk in find what p...

WPF xml
I'm using WPF with net 3.5 to load the ItemsSource of a combo box from an xml file. The xml is setup like this: <profiles> <profile> <profilename>First profile</profilename> ... </profile> ... other profile nodes </profiles> In the Windows.Resources node of the xaml I have: <XmlDataProvider x:Key="xmldata" Source="c:/temp/xmlData.xml" XPath="profiles/profile" /> and in the combobox I have: <ComboBox Margin="5" Name="cbProfiles" Width="240" IsE...

Receipt
Does anyone know whether it's possible to use a string as part of the conditional expression ? The code I'm trying to use is : <IF> <CONDITION> Entry.Item.ItemLookupCode = "GV" </CONDITION> <THEN>"XYZ"</THEN> <ELSE>"123"</ELSE> </IF> It's working fine if I replace the "GV" with a number, but always hits the ELSE expression when it's a string. I've also tried using a string variable here, which also fails. tnx TJ Nope, no string comparisons. -- -- Glenn Adams Tiber Creek Cons...

Word document creation in XML
Hi All, I'm pretty new to .Net, not to mention XML, so I truly appreciate any advice! I have user data that I want to selectively insert into a MS Word document in XML. Given the various content, I want to create a new instance of an XML document and write the data to the XML doc using the Word ML schema. The key item is that I want to be able to add content line-by-line or section-by-section, to the word document using the XML schema. The reason behind this is that the content will change dramatically. The question comes down to this -- are there already-defined components that...

How fill Dataset from XML file?
How do I use an XML file to fill a dataset? Any code examples? XML format: <Server> <Name></Name> <Ip></Ip> <OS></OS> </Server> The XML file has 10 of these records. Thanks! I found it! http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vbcode/html/vbtskcodeexamplereadxmlintodatasetfromxmlfile.asp "VB Programmer" <growN0SPAM@go-intechN0SPAM.com> wrote in message news:%23wswLBQOEHA.3708@TK2MSFTNGP10.phx.gbl... > How do I use an XML file to fill a dataset? Any code examples? > > XML f...

ASP.NET Caching XML
In the world of MSXML 4.0 - one of the techniques used was caching the DomDocument in the application cache with ASP. Updates made to individual nodes could occur concurrently. Is this still possible in .NET? Or is the a better design to use. Paul Jansz wrote: > In the world of MSXML 4.0 - one of the techniques used was caching the > DomDocument in the application cache with ASP. > Updates made to individual nodes could occur concurrently. > > Is this still possible in .NET? Or is the a better design to use. I believe the same goes for System.Xml.XmlDocument class of .NE...

How do I add Yahoo email to Outlook
I have the free version of the Yahoo email account. How do I put it in Outlook like my hotmail account. -- Jeff Mu�iz Work is victory. - Ralph Waldo Emerson You have to subscribe to Yahoo! Plus mail servce. Then it will give you a POP3 access, which you can add to your outlook. Regards Saurabh "Jeff Mu�iz" <jmuniz6@cox.net> wrote in message news:neVKd.22270\$B95.5224@lakeread02... >I have the free version of the Yahoo email account. How do I put it in >Outlook like my hotmail account. > > -- > Jeff Mu�iz > > Work is victory. - Ralph Waldo Emers...

character attributes lost (eg font, italics, bold) when cutting/pasting from excel to quark
hi all, I can cut/paste from excel to quark, but I lose the character attributes (eg font, italics/bold) in the cut/paste, though the text is pasted. I'm new to this so I don't know whether this is a quark limitation, or limitation of windows cut amd paste, or my inexperience. thanks in advance. What is a QUARK??? Isn't that a star that exploded in space 1 billion years ago? >-----Original Message----- >hi all, > >I can cut/paste from excel to quark, but I lose the character attributes >(eg font, italics/bold) in the cut/paste, though the text is pasted. ...