Javascript 使用phpword将d3缩进树转换为ms word

Javascript 使用phpword将d3缩进树转换为ms word,javascript,xml,d3.js,ms-word,phpword,Javascript,Xml,D3.js,Ms Word,Phpword,是我尝试做的一个很好的参考 我希望在MicroSoft word中插入缩进的树。我正在考虑使用phpword中的文本框作为d3树中的矩形 d3有xml数据。如果我循环遍历xml数据以获取其内容,那么我认为这是可以做到的。以下是xml: <svg xmlns="http://www.w3.org/2000/svg" width="1100" height="650" style="background-color: rgb(247, 247, 247);"> <g transf

是我尝试做的一个很好的参考

我希望在MicroSoft word中插入缩进的树。我正在考虑使用phpword中的文本框作为d3树中的矩形

d3有xml数据。如果我循环遍历xml数据以获取其内容,那么我认为这是可以做到的。以下是xml:

<svg xmlns="http://www.w3.org/2000/svg" width="1100" height="650" style="background-color: rgb(247, 247, 247);">
 <g transform="translate(20,30)">
<path class="link" d="M0,0C10,0 10,23 20,23" style="fill: none; stroke: rgb(158, 202, 225); stroke-width: 1.5px;"/>
<g class="node" transform="translate(0,0)">
    <rect y="-10" height="20" width="968" style="fill: rgb(223, 233, 243);"/>
    <text x="0" dy="3.5" dx="5.5" style="font-size: 10px;">PBFT SPC OCAP</text>
    <text class="redirect_link" dy="3.5" dx="5.5" x="888" style="font-size: 10px; text-decoration: underline; font-weight: bold;"/>
</g>
<g class="node" transform="translate(20,23)">
    <rect y="-10" height="20" width="948" style="fill: rgb(148, 189, 218);"/>
    <text x="0" dy="3.5" dx="5.5" style="font-size: 10px;">Perform SPC Data Monitoring using SPC system based control chart</text>
    <text class="redirect_link" dy="3.5" dx="5.5" x="868" style="font-size: 10px; text-decoration: underline; font-weight: bold;"/>
</g>

使用上面的xml数据,如何循环遍历该数据并将数据插入phpword?

PHP在服务器上运行,而D3在浏览器中运行。您需要将D3生成的内容发送回服务器。当D3在浏览器中运行时,PHP在服务器上运行。您需要将D3生成的内容发送回服务器。
 $phpWord = new \PhpOffice\PhpWord\PhpWord();

 $section = $phpWord->addSection();

// In section
$textbox = $section->addTextBox(
array(
    'align'       => 'center',
    'width'       => 400,
    'height'      => 150,
    'borderSize'  => 1,
    'borderColor' => '#FF0000',
)
);

  $textbox->addText(htmlspecialchars('Text box content in section.'));