Hi Bitnugger
vielen Dank für die so schnelle Antwort!! Anhand Deiner Angaben habe ich es tatsächlich so hinbekommen, dass ich schlussendlich einen kompletten html-String erhalte, mit 1 Tabelle pro gefundenem Eintrag. Für Dich als Profi ist es vermutlich Gebastel, würde mich aber trotzdem interessieren, wie Du dieses bewertest. Der Einfachheit halber notiere ich nur die Funktion _Response_XML_To_Array($sResponse) hier unten:
HTML
Func _Response_XML_To_Array($sResponse)
Local $html_string = '<html><body>'
Local $oXML = ObjCreate("Msxml2.DOMDocument")
$oXML.load('api-response.xml')
Local Static $aTel[1][12] = [['content', 'tel:pos', 'tel:id', 'tel:type', 'tel:name', 'tel:firstname', 'tel:occupation', 'tel:street', 'tel:streetno', 'tel:zip', 'tel:city', 'tel:phone']]
Local Static $oElemList = $oXML.SelectNodes('//feed/entry/tel:extra')
Local Static $aInf[12] = _
[ 'Zusammenfassung:', _ ; content
'Pos:', _ ; tel:pos
'ID:', _ ; tel:id
'Art:', _ ; tel:type
'Nachname/Firma:', _ ; tel:name
'Vorname:', _ ; tel:firstname
'Beruf:', _ ; tel:occupation
'Strasse:', _ ; tel:street
'Nr:', _ ; tel:streetno
'PLZ:', _ ; tel:zip
'Ort:', _ ; tel:city
'Tel:' _ ; tel:phone
]
If Not FileExists($sResponse) Then Exit MsgBox(16, @ScriptName, 'Error: File "' & $sResponse & '" not found!')
Local $oXML = ObjCreate("Microsoft.XMLDOM")
If Not $oXML.load($sResponse) Then Exit MsgBox(16, @ScriptName, 'Error by $oXML.load --> "' & $sResponse & '"')
Local $iIndex, $aContent
For $i = 0 To UBound($aTel, 2) - 1 Step 1
$iIndex = 1
$oInfos = $oXML.SelectNodes("//feed/entry/" & $aTel[0][$i]) ; or //Other
For $oInfo In $oInfos
If $i = 0 Then ReDim $aTel[UBound($aTel) + 1][12]
If _ArraySearch($aTel, $oInfo.NodeName, 0, 0) = -1 Then ContinueLoop
$aTel[$iIndex][$i] = $oInfo.Text
Do
$aTel[$iIndex][$i] = StringReplace($aTel[$iIndex][$i], ' ', ' ')
Until @extended = 0
$aTel[$iIndex][$i] = StringReplace($aTel[$iIndex][$i], @LF, ';')
$iIndex += 1
Next
Next
If UBound($aTel) < 2 Then Return SetError(1, 0, False) ; keine Einträge gefunden
ConsoleWrite(@CRLF)
For $i = 1 To UBound($aTel) - 1 Step 1
$html_string &= '<table width=400>'
For $j = 0 To UBound($aTel, 2) - 1 Step 1
If $j = 0 Then
$aContent = StringSplit($aTel[$i][$j], '; ', 3)
If @error Then ContinueLoop
;~ _ArrayDisplay($aContent, '$aContent')
;~ _CW(StringFormat('%-56s: %s\r\n', $aInf[$j], $aContent[0]))
For $k = 1 To UBound($aContent) -1 Step 1
_CW(StringFormat('%-56s: %s\r\n', '', $aContent[$k]))
Next
Else
If $aTel[$i][$j] = '' Then ContinueLoop
_CW(StringFormat('%-56s: %s\r\n', $aInf[$j], $aTel[$i][$j]))
$html_string &= '<tr><td width=150 align=left>' & $aInf[$j] & '</td><td width=250 align=left>' & $aTel[$i][$j] & '</td></tr>'
EndIf
Next
$html_string &= '</table>'
Next
For $oElem In $oElemList
$oAttributes = $oElem.attributes
$iAttribute = 0
For $oAttribute In $oAttributes
$iAttribute += 1
If $oAttribute.name = 'type' Then
$html_string &= '<tr><td width=150 align=left>' & $oAttribute.value & '</td><td width=250 align=left>' & $oElem.Text & '</td></tr>'
;~ ConsoleWrite(StringFormat('> .NodeName = %-22s .Text = %-42s .nodeTypeString = %-20s .nodeType = %s $iAttribute = %i $oAttribute.name = %s $oAttribute.value = %s\r\n', _
;~ $oElem.NodeName, $oElem.Text, $oElem.nodeTypeString, $oElem.nodeType, $iAttribute, $oAttribute.name, $oAttribute.value))
EndIf
Next
Next
$html_string &= '</body></html>'
_CW($html_string)
Return $html_string
EndFunc ;==>_Response_XML_To_Array
Alles anzeigen