Click here to Skip to main content
15,896,730 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have an xml file named "sysparam.xml" contain:

XML
<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 :

VB
 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

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
 
Share this answer
 
Comments
Abhinav Gauniyal 2-Oct-13 14:41pm    
Lot of XML queries these days :) , for more info : see here
Sergey Alexandrovich Kryukov 2-Oct-13 16:08pm    
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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900