我正在使用powershell,我必须读取并解析XML,它在Windows任务调度程序中创建一个计划任务,作为字符串。一切顺利,但一旦我尝试注册计划任务,它就说XML格式不正确。精确的问题是在XML文件中的Action标记下的Arguments子标记中。 请参考以下代码:
<Arguments>-Command "& { & "./pl.ps1 {plname} run" } "</Arguments>
答案 0 :(得分:1)
&#34;&amp;&#34;必须转义字符。它必须作为
进入现场<Arguments>-Command "& { & "./pl.ps1 {plname} run" } "</Arguments>
通过搜索格式良好的XML&#34;。
,可以找到更多信息答案 1 :(得分:0)
或者您可以将CDATA添加到标签中:
function getAllUserContacts(users, callback){
var index = 0;
var results = [];
var getUserContacts = function(){
getContactsOfUser(users[index].userId, function(contacts){
var index2 = 0;
var getContactsPhones = function(){
getPhonesOfContacts(contacts[index2].contactId, function(phones){
contacts[index2].phones = phones;
if(index2 === (contacts.length - 1)){
users[index].contacts = contacts;
if(index === (users.length - 1)){
callback(users)
} else {
index++;
getUserContacts();
}
}else{
index2++;
getContactsPhones();
}
});
}
getContactsPhones();
});
}
getUserContacts();
}
//calling the function
getAllUsers(function(users){
getAllUsersWithTheirContacts(users, function(usersWithContacts){
console.log(usersWithContacts);
})
})
在CDATA中,您可以添加所需的每个字符(“]”除外)。