1
Answer

Creating a dll for XML Operations

oc A

oc A

14y
2.9k
1
Hi All,

I want to create a dll in VB.NET. The functionality of the dll is that it should include all the xml operations. Any application that uses this dll will just pass the node that has to be selected. The dll will accept the node name and search for the node in the xml file and return the details of the node. For example:
if the xml file is like

<Node1>
       <Node2>
              <Node21 Attribute1 = "Value1" Attribute2 = "Value2" />
              <Node22 Attribute1 = "Value11" Attribute2 = "Value22" />
              <Node23 Attribute1 = "Value111" Attribute2 = "Value222" />
       </Node2>
       <Node3>
              <Node31 Attribute1 = "Value1" Attribute2 = "Value2" />
              <Node32 Attribute1 = "Value11" Attribute2 = "Value22" />
              <Node33 Attribute1 = "Value111" Attribute2 = "Value222" />
       </Node3>
</Node1>

If the application which uses the dll calls a function named readNode(Node3) which is defined in the dll, then the dll should be able to retrieve all the details of Node3 including subnodes and theire attribute values and return it to the calling application. All the XML operations are to be done in the dll. The calling application will just call the method in the dll by passing the node name and it should be able to get all the node or attribute values.

Can anybody please advice me the best way of doing this both memory wise and performance wise.

Any help will be highly appreciated.
Thanks in advance

:)


Answers (1)
0
Andrew Fenster

Andrew Fenster

NA 2.2k 1.5m 14y


That's not hard to do.   You can open your current solution and add a new project.  The project type should be "class library."  In this project you put whatever classes you want.  The classes and methods you want to be accessible should be marked public.  The classes and methods you don't want other projects to access should be marked private or internal. 
 
My suggestion is that you make a class with a name like XmlUtilities.  This class should have a series of public static methods to parse XML. 
In your other projects / web applications / batch jobs that need to call your XmlUtilties, you right click on the project name in the solution explorer and add a reference to your new class library.

Your class library will compile into a .dll.  Your other projects, once you add a reference, will make a copy of the .dll and put it in their bin folder.  So each project / website / etc. will have a copy of the .dll.  Normally that would be fine.  If you are really worried about having multiple copies of the .dll, you can copy the .dll into the GAC (Global Access Cache) and then have all your other projects add a reference to that copy.  That's a much more involved effort, and it sounds like overkill for your project.

Good luck.