I am extracting some xml files into a database using vb.net but i am having trouble to identify a line in the xml tag with
The xml looks like that:
<article type="article">
<id>0103-0002-004</id>
<?article zz="3100222857"?>
</article>
I am using:
Dim articles As IEnumerable(Of XElement) = docIssues...<article>
For Each article As XElement In articles
strIdXML = article.Element("id")
strIdXML = IIf(strIdXML Is Nothing, "element does not exist", strIdXML)
strGaleId = article.Element("ariticle")
strGaleId = IIf(strGaleId Is Nothing, "element does not exist", strGaleId)
next
It is fine with the id but i can't manage to get this
Any clues?
Thanks a lot
It's not an element, so accessing it via the Element()
function seems wrong. I think that something like:
Dim articlePI = article.DescendantNodes()
.SingleOrDefault(
Function(node)
If Typeof node is XProcessingInstruction
Dim pi = DirectCast(node,XProcessingInstruction)
Return pi.Target = "article"
End If
Return False
End Function
)
to extract the item. You'd then want to cast it to XProcessingInstruction
to access it's Data
.