我正在尝试使用ID保存HTTP,就像这样
https://hostname:9060/ers/config/networkdevice/1
Run Code Online (Sandbox Code Playgroud)
在'output.csv'中.之后,我想在我的get请求中使用这些链接,以从管理系统获取有关设备的更多信息.
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<ns3:searchResult total="3" xmlns:ns5="ers.ise.cisco.com" xmlns:ers-v2="ers-v2"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns3="v2.ers.ise.cisco.com">
<ns3:resources>
<ns5:resource id="1"
name="Device1">
<link rel="self" href="https://hostname:9060/ers/config/networkdevice/1"
type="application/xml"/>
</ns5:resource>
<ns5:resource id="2"
name="Device2">
<link rel="self" href="https://hostname:9060/ers/config/networkdevice/2"
type="application/xml"/>
</ns5:resource>
<ns5:resource id="3"
name="Device3">
<link rel="self" href="https://hostname:9060/ers/config/networkdevice/3"
type="application/xml"/>
</ns5:resources>
</ns3:resources>
</ns3:searchResult>
Run Code Online (Sandbox Code Playgroud)
但在使用我的Perl脚本后,我的文件是空的.
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use XML::Simple;
#NOTE: Update this to contain my elements in CSV
my @Fields = qw{id};
my $xml = XMLin('Get_All_Prime.xml', ForceArray => ['link']);
foreach my $link ( @{ $xml->{link} } ) {
print …Run Code Online (Sandbox Code Playgroud)