PHP에 대해 많이 알지는 못하지만 저는 powershell로 변환하려는 PHP 스크립트를 상속 받았습니다. 이것이 가능한지 확실하지 않습니다. 그러나 스크립트가 서비스 목록에서 XML로 제품 목록을 얻는 것처럼 보입니다. 그런 다음 cr/lf 스트립 핑을 수행하고 몇 개의 따옴표 문자를 교환 한 다음 xml을 json으로 변환합니다. 꽤 똑바로 보인다. PowerShell에 대해서는 아직 잘 알지 못하기 때문에 여기에있는 사람에게는 이것이 간단한 작업이되기를 바랍니다. 여기 PHP 대 Powershell 스크립트
<?php
$fileContents= file_get_contents("http://svc.mysite.com/api/GetItems");
$fileContents = str_replace(array("\n", "\r", "\t"), '', $fileContents);
$fileContents = trim(str_replace('"', "'", $fileContents));
$simpleXml = simplexml_load_string($fileContents);
$map = json_decode(json_encode($simpleXml));
print json_encode($map->item);
?>
내가이 함께했다
<?xml version="1.0" encoding="utf-8" ?>
<items xmlns="http://svc.tricorbraun.com/api/GetItems" version="1">
<item><ItemID>000072</ItemID><ItemName>Dropper Tip Closure</ItemName><ItemGroup>Closures</ItemGroup><Shape>Round</Shape><Style>Fitment/Plug</Style></item>
<item><ItemID>000182</ItemID><ItemName>28-480, P/P Push and Turn Closure</ItemName><ItemGroup>Closures</ItemGroup><Shape>Round</Shape><Style>Child Resistant</Style></item>
<item><ItemID>000187</ItemID><ItemName>28-480, P/P Child Resistant Closure</ItemName><ItemGroup>Closures</ItemGroup><Shape>Round</Shape><Style>Child Resistant</Style></item>
<item><ItemID>000190</ItemID><ItemName>28mm SPEC, P/P Dispensing Closure</ItemName><ItemGroup>Closures</ItemGroup><Shape>Round</Shape><Style>Dispensing</Style></item>
</items>
XML 데이터의 샘플이지만,
$doc = New-Object System.Xml.XmlDocument
$memStream = new-object System.IO.MemoryStream
$jsonWriter = [System.Runtime.Serialization.Json.JsonReaderWriterFactory]::CreateJsonWriter($memStream)
$doc.Load("http://svc.mysite.com/api/GetItems")
$doc.Save($jsonWriter)
$bytes = $memStream.ToArray()
[System.Text.Encoding]::UTF8.GetString($bytes,0,$bytes.Length)
Write-Output $jsonWriter.ToString()
언어/시스템을 모르는 경우에는 Q & A 사이트가 아닌 프리랜서가 필요합니다. –
나는 요구 사항을 만드는 사람이 아니다. 우리는 작업을 외주 처리하고이 PHP를 받았습니다. 우리는 명시 적으로 powershell을 요청했습니다. 그것이 더 복잡했다면, 나는 여기에 그것을 제출하지 않았을 것이다. 그러나 필요하다면 나는 스스로 알아낼 것이다. 무료 랜서가 필요하지 않아야합니다. –
하청 업체와 같은 소리는 지정된 제품을 기침 할 때까지 발 구이가 필요합니다. – mjolinor