Click here to Skip to main content
11,707,254 members (46,386 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: 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
0 Sergey Alexandrovich Kryukov 145
1 OriginalGriff 141
2 chainerlt 110
3 Mika Wendelius 80
4 Maciej Los 80
0 OriginalGriff 9,178
1 Sergey Alexandrovich Kryukov 8,562
2 CPallini 5,189
3 Maciej Los 4,806
4 Mika Wendelius 3,706

Advertise | Privacy | Mobile
Web02 | 2.8.150819.1 | Last Updated 18 Jan 2013
Copyright © CodeProject, 1999-2015
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