Click here to Skip to main content
12,890,388 members (57,739 online)
Rate this:
Please Sign up or sign in to vote.
See more: VB VB.NET
I recieved an xml file from a company with their error codes and i'm having problems getting the inner value. what i need is the Text for the error code if someone could help me that would be great. The one requierment my company has is the xml has to be an embeded resource.

     <Error id="102">Name missing from this item in catalog.</Error>

the function i have been trying to create is below but

Function Readerrors(ByVal sError)
    Dim str = ""
    Dim strResources As String = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name & ".Errors.xml"
    Dim document As XPathDocument = New XPathDocument(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(strResources))
    Dim navigator As XPathNavigator = document.CreateNavigator()
    Dim node As XPathNavigator = navigator.SelectSingleNode("//ErrCodes[@id=" & sError & "]")
    str = node.InnerXml
    Return str
End Function
Posted 25-Oct-12 10:38am
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Imports System.Xml
Function ReadErrors()
Dim reader As XmlTextReader = New XmlTextReader("Errors.xml")
Do While (reader.Read())
Select Case reader.NodeType
Case XmlNodeType.Element 'start element ignore it
Case XmlNodeType.Text
return (reader.Value) 'this is the value that you want
Case XmlNodeType.EndElement 'end of element ignore it
End Select
play with this code to get what you need, but I think this is your answer.

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

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170424.1 | Last Updated 18 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

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