DOM

israel4ever

New member
DOM ../images/Emo58.gif

היי אני מנסה לבנות פונקציה מסויימת שקוראת דף XML בעזרת ה-DOM. עכשיו הפונקציה קוראת מהדף הזה: http://www.bankisrael.gov.il/heb.shearim/currency.php המטרה של הפונקציה הוא לקבל את שם המטבע מהמשתמש ולתת את את הערך של המטבע. הפונקציה שכתבתי נראת ככה:
Private Function ReceiveValue(ByVal ConvertType As String) As String Dim objDoc As New XmlDocument() Dim sValue As String objDoc.Load(Server.MapPath("..\XMLfile.xml")) Dim xmlNode As XmlNode = objDoc.SelectSingleNode("/CURRENCIES/CURRENCY") If xmlNode.SelectSingleNode("Name").InnerText = ConvertType Then Dim Rate As String = xmlNode.SelectSingleNode("Rate").InnerText Response.Write(Rate) End If End Function​
אבל יש בעיה בקוד הזה... מישהו יכול לשפר לי את הפונקציה הזו? תודה מראש
 

yuval k

New member
עוד לפני שנקרא את הקוד שלך...

מה הבעיה שיש בקוד? אם אתה מקבל שגיאה, מהי?
 

israel4ever

New member
פירוט

השגיאה היא:
Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.​
והשורה המסומנת היא:
If xmlNode.SelectSingleNode("Name").InnerText = ConvertType Then​
יש למישהו רעיון מדוע?
 
למעלה