I need to read data from an xml file that might have (may not always have) a xmlns attribute. I cant find the nodes because I will not know the prefix. I am new to XML, I have found several solutions including removing the xmlns attribute but it is not for the "new" method of accessing xml using xelement.
Public Function GetHeader(xmlFileName As String, ByRef ispies As Boolean, ByRef isaces As Boolean, ByRef pcdbversiondate As Date, ByRef vcdbversiondate As Date) As String
Dim xmlDoc As XElement
Dim xmlNodes As IEnumerable(Of XElement)
Dim Headertext As String
Dim header As IEnumerable(Of XElement)
xmlDoc = XElement.Load(xmlFileName)
xmlNodes = xmlDoc.Elements()
If InStr(xmlDoc.Name.ToString, "PIES") > 0 Then
ispies = True
End If
If InStr(xmlDoc.Name.ToString, "ACES") > 0 Then
isaces = True
End If
header = From nm In xmlDoc.Elements("Header")
Headertext = ""
For Each ele As XElement In header
For Each cn As XElement In ele.Descendants
Headertext += cn.Name.ToString & "=" & cn.Value & vbCrLf
If cn.Name.ToString = "VcdbVersionDate" Then
vcdbversiondate = fixDate(cn.Value.ToString)
End If
If cn.Name.ToString = "PcdbVersionDate" Then
pcdbversiondate = fixDate(cn.Value.ToString)
End If
Next
Next
GetHeader = Headertext
End Function