1
我只是想抓住從iphone的XML後埃夫裏的節點,例如這是我需要「搞定」如何從Asp中的iphone中獲取http post中的所有節點?
<Matchs>
<owner>Me</owner>
<typeAction>Me</typeAction>
<match id=21>sept 3 2011 </match>
<match id=22>sept 4 2011 </match>
<match id=23>sept 5 2011 </match>
</Matchs>
我能夠得到的每一個節點,但是當有XML文件不止一個節點有我不知道如何做到這一點的同名...
這是我的代碼來獲取值:
Public Shared Function TryParse(ByVal value As String, ByRef notification As MatchModel) As Boolean
Dim success As Boolean = False
notification = Nothing
Try
Dim xReader As System.Xml.XmlReader = System.Xml.XmlReader.Create(New System.IO.StringReader(value))
Dim element As System.Xml.Linq.XElement = System.Xml.Linq.XElement.Load(xReader)
notification = New MatchModel()
' Populate the top XML elements values
Dim wItem As System.Xml.Linq.XElement = Nothing
Dim actual As matchAlone = Nothing
While xReader.MoveToElement()
If element IsNot Nothing Then
wItem = element.Element("match")
actual.Description = GetXElementValue(element, "match")
actual.Id = GetWorkItemAttributeValue(wItem, "id")
End If
End While
notification.Owner = GetXElementValue(element, "owner")
notification.TypeAction = GetXElementValue(element, "typeAction")
success = True
Catch e As Exception
Console.WriteLine(e.Message)
End Try
Return success
End Function
Public Shared Function GetXElementValue(ByVal element As System.Xml.Linq.XElement, ByVal name As System.Xml.Linq.XName) As String
Dim value As String = Nothing
If element IsNot Nothing Then
value = element.Element(name).Value
End If
Return value
End Function
Public Shared Function GetWorkItemAttributeValue(ByVal element As System.Xml.Linq.XElement, ByVal name As System.Xml.Linq.XName) As String
Dim value As String = Nothing
If element IsNot Nothing Then
value = element.Attribute(name).Value
End If
Return value
End Function
請heeeeeelp :)
非常感謝你它很好:) –