0

我试图获得一些有关 XML 的帮助。我在网上找到了一些很好的代码示例,它适用于我想要获得的大部分内容,但并非适用于所有人。对此的任何帮助都会很好。我只得到组合数据。我正在研究如何在一个对象的循环中获取“ns0:NarrativeCreateDatetime”,在另一个对象中获取“ns0:NarrativeText”。

谢谢费尔南多

部分xml文件:

2012 年 9 月 14 日 07:49:23 - E911 信息 - 服务等级:BUSN

for Each item As System.Xml.XmlElement In Narrative
        If Not item.InnerText = "" Then

            objNarrative = item.InnerText
            x += 1
        End If
    Next
4

1 回答 1

0
For Each item As System.Xml.XmlElement In DispatchTime
        If Not item.InnerText = "" Then
            For Each UnitNumber As System.Xml.XmlElement In item.GetElementsByTagName("ns0:UnitNumber")
                objUnitNumber = UnitNumber.InnerText
            Next
            For Each Dispatched As System.Xml.XmlElement In item.GetElementsByTagName("ns0:Dispatched")
                objUnitDispatched = Dispatched.InnerText
            Next
            For Each Enroute As System.Xml.XmlElement In item.GetElementsByTagName("ns0:Enroute")
                objUnitEnRoute = Enroute.InnerText
            Next
            For Each AtScene As System.Xml.XmlElement In item.GetElementsByTagName("ns0:AtScene")
                objUnitAtScene = AtScene.InnerText
            Next
            For Each InService As System.Xml.XmlElement In item.GetElementsByTagName("ns0:InService")
                objUnitInService = InService.InnerText
            Next
            ' Add Code to insert to DB



            objUnitNumber = ""
            objUnitDispatched = ""
            objUnitEnRoute = ""
            objUnitAtScene = ""
            objUnitInService = ""
        End If
    Next
于 2012-09-15T02:35:07.463 回答