Click here to Skip to main content
14,367,980 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have an xml file named "sysparam.xml" contain:

<Name>Jack</Name>
<LastName>Jerald</LastName>


i want a class in vb.net that return the inner text of the node as a string where the method should look like :

 Function GetParamValue(ByVal oKey As String) As String
.
.
.
.
end function



Any Help Please
Posted
Comments
Richard C Bishop 2-Oct-13 11:12am
   
Help with what? Read the file and assign the text to a string object.
ZurdoDev 2-Oct-13 11:12am
   
Use the XDocument class or the XmlDocument class.
[no name] 2-Oct-13 11:21am
   
its my first time i use the xml so i dont know how to use it
ZurdoDev 2-Oct-13 11:37am
   
Google for those classes and there will be examples on how to use them.

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

As .NET FCL provides different ways for parsing and generating XML, you have to pick up what will suit you the most. This is my short overview:


  1. Use System.Xml.XmlDocument class. It implements DOM interface; this way is the easiest and good enough if the size if the document is not too big.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^].
  2. Use the classes System.Xml.XmlTextWriter and System.Xml.XmlTextReader; this is the fastest way of reading, especially is you need to skip some data.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmlwriter.aspx[^], http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx[^].
  3. Use the class System.Xml.Linq.XDocument; this is the most adequate way similar to that of XmlDocument, supporting LINQ to XML Programming.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^], http://msdn.microsoft.com/en-us/library/bb387063.aspx[^].


Good luck,
—SA
   
Comments
Abhinav Gauniyal 2-Oct-13 14:41pm
   
Lot of XML queries these days :) , for more info : see here
   
This is the same thing, I put the same answer...
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100