он работает без registerXPathNamespace
и полного префикса пространства имен в запросах xpath:
$xml = new SimpleXMLElement($r);
foreach($xml->xpath('//event:event') as $event) {
var_export($event->xpath('event:sessionKey'));
}
Вот один из способов сделать это:
Sub Tester()
CreateSheets 4
End Sub
'EDIT: added specific workbook reference to qualify sheet references
Sub CreateSheets(howMany As Long)
Dim nm As String, sht As Worksheet
Dim i As Long, n As Long, wb As Workbook
Set wb = ThisWorkbook
For n = 1 To howMany
i = 2
Do
nm = Format(i, "000")
Set sht = Nothing
'see if this sheet exists...
On Error Resume Next
Set sht = wb.Sheets(nm)
On Error GoTo 0
If sht Is Nothing Then
'get the sheet to copy the template after
Set sht = wb.Sheets(Format(i - 1, "000"))
wb.Sheets("001").Copy after:=sht
wb.Sheets(sht.Index + 1).Name = nm
Exit Do 'made our copy
End If
i = i + 1
Loop
Next n
End Sub