how to add or remove entity to a xml file

could someone tell me how to add or remove entity to a xml file

when i dim xmlentity as new xmlentity
it's say it's sube new is private

Terry (158)
6/10/2004 3:34:25 PM
dotnet.xml 7266 articles. 0 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 31

"terry" <> wrote in message
> could someone tell me how to add or remove entity to a xml file

XmlEntity can't be directly instantiated, you have to work through the InternalSubset
of the DTD (as represented by the XmlDocumentType class).  When you specify
the InternalSubset for an XmlDocumentType object that you can create through
an XmlDocument's CreateDocumentType( ) method, .NET will parse the Entities
and build a collection of XmlEntity objects for you.

Given the following XML document,

- - - book.xml
<!DOCTYPE book [<!ENTITY h 'hardcover'>]>
<book genre='technology' ISBN='0-764548-26-3'>
    <title>Visual Basic .NET Bible</title>
- - -

You might load it with the following VB.NET code,

    Dim xmlDoc As New XmlDocument( )
    xmlDoc.Load( "book.xml")

Then you'd create a pair of XmlDocumentType objects,

    Dim oldDTD As XmlDocumentType = xmlDoc.DocumentType
    Dim newDTD As XmlDocumentType

    newDTD = xmlDoc.CreateDocumentType( _
        oldDTD.Name, _
        oldDTD.SystemId, _
        "<!ENTITY h 'softcover'>" _

Notice that I've used the CreateDocumentType( ) method of the XmlDocument
to create the new DTD.  I copy it's primary characteristics (name, public and
system identifiers) from whatever the old DTD contained, and then I supply the
text of the internal subset I wish the DTD to use (it's left as an exercise for the
reader to enumerate Entities and Notations of the existing DTD to be maintained;
Hint: you can start by using the XmlDocumentType's InternalSubset string property
as the basis for keeping/revising tracts of text).  In the replacement entity here,
I've redefined &h; to refer to the literal text, "softcover," instead of "hardcover."

Now, an XmlDocument can only have one XmlDocumentType.  So to apply this
XmlDocumentType, and it's newly created Entities, I must replace the existing
XmlDocumentType node like so,

    xmlDoc.ReplaceChild( newDTD, oldDTD)

If I now examine the contents of the DTD on the XmlDocument, I can see the
changes have taken effect.

    Console.WriteLine( xmlDoc.DocumentType.OuterXml)

Finally, the XmlEntity that you wanted to create (to recap, it was the following
text I passed to the internalSubset argument of CreateDocumentType( )):

    <!ENTITY h 'softcover'>

has been created for you in the Entitites collection of xmlDoc.DocumentType.
It can be examined like this:

    Dim entity As XmlEntity = CType( xmlDoc.DocumentType.Entities, GetType( XmlEntity))
    Console.Write( "{0} ", entity.NodeType)
    Console.Write( "{0} ", entity.Name)
    Console.Write( "{0} ", entity.NotationName)
    Console.Write( "{0} ", entity.PublicId)
    Console.Write( "{0} ", entity.SystemId)
    Console.Write( "{0} ", entity.InnerText)

Derek Harmon

loresayer (276)
6/11/2004 2:44:46 AM
"Derek Harmon" <> wrote in message news:#yxMx81TEHA.3140@tk2msftngp13.phx.gbl...
>     Dim entity As XmlEntity = CType( xmlDoc.DocumentType.Entities, GetType( XmlEntity))

Gnit.  :-)   This line should read,

    Dim entity As XmlEntity = CType( _
        xmlDoc.DocumentType.Entities.Item( 0), _
        GetType( XmlEntity) _

The type cast was meant on the XmlNode returned from the
XmlNamedNodeMap, not the XmlNamedNodeMap itself.  :-/

Derek Harmon

loresayer (276)
6/11/2004 2:55:07 AM

Similar Artilces:

What bloated my Outlook.pst file?
Strange story, but true. My Outlook.pst file was getting rather large, over 47 MB, so I decided to do some cleaning. I deleted many unnecessary e-mails (a large portion of my Inbox) , then deleted them from the "Deleted Items" folder. I was surprised, however, to look in my Outlook data folder after that, and saw that the size of the file had increased to over 97 MB, more than double! (I could understand it not decreasing yet, as I hadn't compacted it yet, but didn't understand the increase!) I then compacted it. That shrank it to over 87MB, less than the 97MB+, but still ...

Office 2007
My new laptop came with a trial version of Office 2007, which I will eventually remove. Question: can I simply uninstall this product BEFORE use, using my Control Panel options or can I use the product for 60 days, then uninstall with equal "efficiency." In other words, if I uninstall before use will the uninstall be more effective in removing all traces than if I used the product, then uninstall? Thanks... EW Either one will work as well, unless uninstall screws up somehow and you have to uninstall by hand. Bookmark the following page, "just in case&quo...

Add Lookup Fields to Entity
I need to add 4 "technical contact" fields (which would lookup the Contact entity) to the CONTRACT form. Is this possible? I've found it difficult to figure out what to do first. Thanks in advance, Brandon Not possible. You cant have multiple lookups for the same entity. You also cannot create new relationships between two system entitites. This will work in 4.0 Not possible, Pezman. N:M relationships are not possible in 3.0 yet. There is a alternative solution: a new entity to act as an N:M relationship. In your case, Contract/Contact. This entity has two 1:N relations...

log file of email open time/date
Hi, I needed to know if there is a way to keep a log file or to view information about when the emails I receive are opened. I probably needed information like date and time. I am the person opening the emails but I needed to show someone when I opened them. Emails are coming from various different people using different email software, so it can't be tracked from their end. I have Outlook 2000, but might need to use it in different versions of Outlook. so if you know of a feature that I can use, can you also tell me if it's available for different versions? thanks a lot. I apprec...

Problems creating a PDF file from a report using autoexec macro
Hi, I am using the autoexec macro to run a report and print it out as a pdf file. My steps in the autoexec macro are 1. OpenReport 2. Print Out 3. RunCode 4. Quit. The RunCode is designed to delay the closing of the application by two minutes so that the pdf file can be created. Whenever I run this, I get a box that comes up and says "Print Macro Definitions" Include for Macro _Properties _Actions and Arguments _Permissions by User and Group. The application hangs on this without closing. Can someone tell me what I am doing wrong? Is Print Out the right command? Tha...

Excel Add Ins
What is the name of the template wizard with Data Tracking (Excel. I can not locate the add in template wizard with Data Tracking in Office 2003 Hi Richard You are not the only one<g> The Add-in is working in 2003 only the install file is not working. Copy the xla file from a PC with 2002 to the PC with 2003 and it will work(use Tools>add-ins to browse to the file in Excel) -- Regards Ron de Bruin "Richard" <> wrote in message > What is t...

Open .msi files as a Limited User by using RUNAS
Windows Registry Editor Version 5.00 ; Open .msi files as a Limited User by using RUNAS ; [HKEY_CLASSES_ROOT\Msi.Package\shell\runas\command] @=hex(2):22,00,25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f, 00,6f,00,74,\ 00,25,00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c, 00,6d,00,\ 73,00,69,00,65,00,78,00,65,00,63,00,2e, 00,65,00,78,00,65,00,22,00,20,00,2f,\ 00,69,00,20,00,22,00,25,00,31,00,22,00,20,00,25,00,2a,00,00,00 That's all very well, but it's not magic! You will still need the correct password of a valid user profile on that machine, tha...

Add on
Hello, Here is a scenerio. A client is buying 1lb of ham. It is put on a waxed paper then wrapped into a white paper and then put into a shopping bag. The usage of shopping bag is 100% cases the usage of paper is only with certin categories of sales. Same with the waxed paper. Question: Is there a way of associating wax paper, white paper and shopping bags in a way so with every sale a piece of paper gets deducted from inventory and one bag is deducted from inventory? I would like to run a report every so often and see if I need to purchase any supplies. Kits and assembly do not work...

files in OLK folder not being deleted
I having problems with Outlook 2003 not displaying graphics embeded within an email. I've deleted all files in the OLK folder and it works for a few days then I have to delete the files again. I've also tried deleting the folder completely and still the problem returns after a few days use. I thought these were temporary files that should be deleted automatically after the email or Outlook is closed. Why are they not being deleted? I've applied the latest Office patches etc. Hope someone has an answer to the problem. Regards, Lester Bennett Lester Bennett <lbennett@entc...

add a row or column to a single cell in exel
I am trying to split a single cell into 2 rows can you help If I understood correctly you want to enter an entry in two lines in a cell at appropirate place hit lt+enter and again hit enter for e.g venkat (alt+enter) raman(enter) "trev" <> wrote in message > I am trying to split a single cell into 2 rows can you help ...

Linq to XML?
I have five items of information I need to extract from XML covering upwards of 25 separate devices. I'm obtaining these values via five Linq to XML queries as follows: IEnumerable<string> EIDs = (from env in xdoc.Root.Elements("packet"). Elements(ns1 + "data").Elements(ns2 + "server_group"). Elements(ns2 + "env") select (string)env.Element(ns3 + "eid")); IEnumerable<int> IDs = (from env in xdoc.Root.Elements("packet"). Elements(ns1 + "data").Elem...

way to delete add. fr. auto. email add. function?
Is there a way to delete old or no longer used email addresses that appear in the drop down box when I am addressing a new email? Shebubba wrote: > Is there a way to delete old or no longer used email addresses that appear in > the drop down box when I am addressing a new email? That is the nickname cache. Search and delete the .nk2 file. That's the cache for nicknames (i.e., your manually entered e-mail addresses). If you only want to delete some of them, highlight an entry and hit the delete key. If that doesn't work, use Nirsoft's NK2 Viewer utility (it e...

POS 2009 Add-In: Populating a Task Pad
I would like to create a custom application that has the ability to maintain the items that are on certain Task Pads within POS 2009. These items would all be regular menu items (ex: hamburger, hot dog, french fries, etc) and not functions. For example, if a task pad was supposed to allow the cashier quick access to daily specials, then this custom application would need to be able to clear the task pad each day and add the items for that day. Is this going to be possible? Please provide some guidance. Thank you, Sean This is a multi-part message in MIME format. ------=_NextPart_00...

.SRF files are not processed by IIS
Hello, I'm not an IIS expert, so excuse me if this seems like a question I should know the answer to. I was trying to use the CRM 1.2 SDK and was getting a HTTP 405 Not Supported errors from the server. We have another development server, also running 1.2, where the calls go through fine. The difference is that on the machine where everything works when I request a .srf file (ex: http://crmdev/MSCRMServices/BizUser.srf) the file is processed and displays XML output. On the other server, the server that calls fail against, when querying the same response file the contents of the file are...

microsoft word 2003 save multipage doc to multiple files
Hello! Is there any possible way to resolve my problem : I have 60 page document and id like to split this doc to 60 single paged files. Is there any way to do this whit some magic word option? Reagrds - HE ...

Add-in cannot be loaded OL07
Every time I open Outlook 2007 I get an error message regarding an add-in 'DCCExtensions' (DCCEXT32.DLL). It says the add-in cannot be loaded and has been disabled by Outlook. I've been getting this message ever since I uninstalled Winfax. How do I make this error stop appearing? Thanks. -- kapibarra Remove the addin from OL by using Trust Center, Addins. "kapibarra" wrote: > Every time I open Outlook 2007 I get an error > message regarding an add-in 'DCCExtensions' (DCCEXT32.DLL). ...

adding pdf files to a publisher document
I'd like to add a pdf file as a page in Publisher. Can I do this without opening up the pdf file? I can add an object, but pdf is not on the list of objects. No, not unless you have Acrobat (not just the free reader). And even then there seem to be posters who can't but I can with no problem. -- JoAnn Paules MVP Microsoft [Publisher] "campgus" <> wrote in message > I'd like to add a pdf file as a page in Publisher. Can I do this without > opening up the pdf f...

Format text to add character
I have two fields that should match, but one includes special characters while the other does not. Example: Field1 00ABCD123456123 Filed2 00/ABCD/123456/123/SBZ I need to find records where these two fields don't match, either by changing the display of one of them, or a query to compare Field1 character 7-15 with Field2 characters 9-14, 16-18. Hope this makes sense. Can anyone help? Thanks! Take a look at the following from the Access Help file it might be what you're looking for... Extract a part of a text value The following table lists examples of expressions that ...

Identify *.dqy file in Excel #2
Hi, We have some excel files which connects to a ODBC data source (Oracle db) Some of those excel spreadsheets we are not able to edit the data source any longer(which should have brought us into Ms query) What happens when we try is that Ms query opens very shortly and then closes again before we can see the query that have been build) My question is now - is there some way that we can identify what data source (the name of the dqy file) that is used in excel...? Thanks Henrik ...

Add File menu to custom toolbar
Hi All, I am trying to add the 'File" menu and "Window" menu of the Standard Toolbar to a custom toolbar but failing miserably! I think it should look something like: Sub AddMenuTitles() Application.CommandBars("MyCustomMenu").Controls.Add("File) Application.CommandBars("MyCustomMenu").Controls.Add("Window") End Sub Can anybody help please Regards Michael Sub test() AddMenuTitles True ' or false to delete End Sub Sub AddMenuTitles(bAdd As Boolean) Dim cbr As CommandBar Dim cbP As CommandBarPopup ...

removed windows live
how do I undo the removal of a program that I removed through my control panel I removed windows live. It appeared that I had two window email program. I want to use window live but I would keep getting windows I had to go around and open msn then go to mail and log in to get around that. I finally removed windows live now it seems I no longer have the program installed. What's even more confusing is that I had placed windows live hotmail on my favorites and now I can get the hotmail but I don't see it in my PROGRAMS. What a mess. help. "...

File Creation
I want to import my database table into the sample "Contacts" table. When I open Contacts db and open the Contacts table and then use Get External Data it creates a new table for my data, instead of putting the records into the Contacts table! What can I do? Any instructions will be very much apprecitated. Tks. Hi Harry, Probably the best thing to do is to create an Append query to move the data from the new table to the Contacts table. After running the append query you can delete the other table. On Tue, 11 Nov 2003 21:31:38 -0800, "HarryHot" <anonymous@discus...

how we can remove ...
hello to all, I have 5 frontals with exchange 2003 ent. with nlb, and two they have fallen and not there is way to restart them, there are them format, how we can remove them of the organization and that they don't appear? greetings Miguel Hi Miguel, If an exchange server isn't available anymore to uninstall Exchange, you can delete it from your organization using ESM. Just right-click on the server and select delete. You should check your connectors configuration if the server is present in there, if so remove it there first. Any other roles should also be moved to anothe...

add a DC in a LegSite
Hi, In the disaster recovery plan we want to create a leg site and put a DC in it. Here are some questions on how to achieve this smoothly. 1. Should I create the new site/subnet first and then promote a server in that subnet/site to DC, or should I promote a server in existing site/subnet and then move this DC to the new site/subnet? 2. When promoting a server to DC, should the server be a member server (already joined the domain) or just a workgroup member (no domain membership)? 3. The DC will be an AD-integrated DNS server. Should I install the DNS component (but not confi...

How can I add the customer's PO# to the drop-ship Purchase Order?
Our purchasing agent would like to be able to have the customers PO# from the Sales Transaction Entry screen show up on the PO's. Is this doable in Report Writer or can it not be done? We are using GP v9.0. As I still consider myself a newbie with RW, I would appreciate detailed instructions if possible. Thank you in advance for all responses. It is not possible thru traditional table relationships in Report Writer. Let me explain: you can certainly link the Purchase Order Work table to the SOP_POLink table and the SOP_POLink table to the SOP Transactions Work table, but will...