Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用PHP将JSON格式的Instagram API转换为XML?_Php_Xml_Json - Fatal编程技术网

如何使用PHP将JSON格式的Instagram API转换为XML?

如何使用PHP将JSON格式的Instagram API转换为XML?,php,xml,json,Php,Xml,Json,我目前正在努力将JSON从instagram API转换为XML,这样我就可以将其应用到我的web中。 API URI的示例: 结果: 我如何使用PHP将其转换为XML,如下所示 <products> <category categoryName="Electronics"> <product productName="Camera Lenses Collection" productID="DSCF0001" thumbPath="thumbs/Elect

我目前正在努力将JSON从instagram API转换为XML,这样我就可以将其应用到我的web中。 API URI的示例: 结果:

我如何使用PHP将其转换为XML,如下所示

<products>
<category categoryName="Electronics">
    <product productName="Camera Lenses Collection" productID="DSCF0001" thumbPath="thumbs/Electronics/camera_lenses_collection-other.jpg" productPrice="250.50">
        <details>
        <![CDATA[
        <p class="four">You can place your HTML CSS formatted content</p>
    <p><strong>Lorem Ipsum</strong> is simply dummy text of the printing and  typesetting industry. <span class="three">Lorem Ipsum has been the industry's standard </span>dummy text ever since the 1500s, when an unknown printer took a galley  of type and scrambled it to make a type specimen book. It has survived  not only five centuries, but also the leap into electronic typesetting,  remaining essentially unchanged. It was popularised in the 1960s with  the release of Letraset sheets containing Lorem Ipsum passages, and  more recently with desktop publishing software like Aldus PageMaker  including versions of Lorem Ipsum.</p>
    <p><img src="images/Electronics/camera_lenses_collection-other.jpg" /><strong>Lorem Ipsum</strong> is simply dummy text of the printing and  typesetting industry. <span class="three">Lorem Ipsum has been the industry's standard </span>dummy text ever since the 1500s, when an unknown printer took a galley  of type and scrambled it to make a type specimen book. It has survived  not only five centuries, but also the leap into electronic typesetting,  remaining essentially unchanged. It was popularised in the 1960s with  the release of Letraset sheets containing Lorem Ipsum passages, and  more recently with desktop publishing software like Aldus PageMaker  including versions of Lorem Ipsum.</p> 
    ]]></details>
</product>
</category>

您可以放置HTML CSS格式的内容

Lorem Ipsum只是印刷和排版行业的虚拟文本。自16世纪以来,Lorem Ipsum一直是行业标准的虚拟文本,当时一位不知名的印刷商拿起一个打印工具,将其拼凑成一本打印样本书。它不仅存活了五个世纪,而且还跨越到电子排版,基本上保持不变。它在20世纪60年代随着包含Lorem Ipsum段落的Letraset表单的发布而流行,最近随着Aldus PageMaker等桌面出版软件的发布,包括Lorem Ipsum版本

Lorem Ipsum只是印刷和排版行业的虚拟文本。自16世纪以来,Lorem Ipsum一直是行业标准的虚拟文本,当时一位不知名的印刷商拿起一个打印工具,将其拼凑成一本打印样本书。它不仅存活了五个世纪,而且还跨越到电子排版,基本上保持不变。它在20世纪60年代随着包含Lorem Ipsum段落的Letraset表单的发布而流行,最近随着包括Lorem Ipsum版本的Aldus PageMaker等桌面出版软件的发布而流行。

]]>

试试这个。你可以在这里看到另一个问题和一些可能有用的示例答案。同样,您也可以使用json_解码

你可以参考这篇文章,我在用foreach创建XML时遇到了一个问题。看看这个XML结果:(我不能在这里粘贴格式化的XML)。问题是:Value productName=“Sushi自制”和productPrice=“50.000”仅适用于productID=“002”。但是为什么该值也填充到下一个productID>=002。不管怎样,我忘了添加ifelse条件。感谢您的回复:)
<products>
<category categoryName="Electronics">
    <product productName="Camera Lenses Collection" productID="DSCF0001" thumbPath="thumbs/Electronics/camera_lenses_collection-other.jpg" productPrice="250.50">
        <details>
        <![CDATA[
        <p class="four">You can place your HTML CSS formatted content</p>
    <p><strong>Lorem Ipsum</strong> is simply dummy text of the printing and  typesetting industry. <span class="three">Lorem Ipsum has been the industry's standard </span>dummy text ever since the 1500s, when an unknown printer took a galley  of type and scrambled it to make a type specimen book. It has survived  not only five centuries, but also the leap into electronic typesetting,  remaining essentially unchanged. It was popularised in the 1960s with  the release of Letraset sheets containing Lorem Ipsum passages, and  more recently with desktop publishing software like Aldus PageMaker  including versions of Lorem Ipsum.</p>
    <p><img src="images/Electronics/camera_lenses_collection-other.jpg" /><strong>Lorem Ipsum</strong> is simply dummy text of the printing and  typesetting industry. <span class="three">Lorem Ipsum has been the industry's standard </span>dummy text ever since the 1500s, when an unknown printer took a galley  of type and scrambled it to make a type specimen book. It has survived  not only five centuries, but also the leap into electronic typesetting,  remaining essentially unchanged. It was popularised in the 1960s with  the release of Letraset sheets containing Lorem Ipsum passages, and  more recently with desktop publishing software like Aldus PageMaker  including versions of Lorem Ipsum.</p> 
    ]]></details>
</product>
</category>