protected function sendNewsMsgToXmlString(WxSendNewsMsg $msg)
    {
        $itemArray  = $msg->getAllArticleItems();
        $itemStr    = '';
        foreach ($itemArray as $item) {
            $itemStr .= $this->sendNewsItemToXmlString($item);
        }

        $formatStr = <<<XML
<xml>
<ToUserName><![CDATA[%s]]></ToUserName>
<FromUserName><![CDATA[%s]]></FromUserName>
<CreateTime>%d</CreateTime>
<MsgType><![CDATA[%s]]></MsgType>
<ArticleCount>%d</ArticleCount>
<Articles>
%s
</Articles>
</xml>
XML;

        $result = sprintf($formatStr,   $msg->getToUserName(),
                                        $msg->getFromUserName(),
                                        strtotime($msg->getCreateTime()),
                                        $msg->getMsgType(),
                                        $msg->getArticleCount(),
                                        $itemStr
                        );

        return $result;
    }
protected function sendNewsMsgToXmlString(WxSendNewsMsg $msg)
    {
        $itemArray  = $msg->getAllArticleItems();
        $itemStr    = '';
        foreach ($itemArray as $item) {
            $itemStr .= $this->sendNewsItemToXmlString($item);
        }

        $formatStr = <<<XML
<xml>
<ToUserName><![CDATA[%s]]></ToUserName>
<FromUserName><![CDATA[%s]]></FromUserName>
<CreateTime>%d</CreateTime>
<MsgType><![CDATA[%s]]></MsgType>
<ArticleCount>%d</ArticleCount>
<Articles>
%s
</Articles>
</xml>
XML;

        $result = sprintf($formatStr,   $msg->getToUserName(),
                                        $msg->getFromUserName(),
                                        strtotime($msg->getCreateTime()),
                                        $msg->getMsgType(),
                                        $msg->getArticleCount(),
                                        $itemStr
                        );

        return $result;
    }
protected function sendNewsMsgToXmlString ( WxSendNewsMsg $ msg ) { $ itemArray = $ msg -> getAllArticleItems ( ) ; $ itemStr = '' ; foreach ( $ itemArray as $ item ) { $ itemStr .= $ this -> sendNewsItemToXmlString ( $ item ) ; } $ formatStr =  <<<XML
<xml>
<ToUserName><![CDATA[%s]]></ToUserName>
<FromUserName><![CDATA[%s]]></FromUserName>
<CreateTime>%d</CreateTime>
<MsgType><![CDATA[%s]]></MsgType>
<ArticleCount>%d</ArticleCount>
<Articles>
%s
</Articles>
</xml>
XML ; $ result = sprintf ( $ formatStr , $ msg -> getToUserName ( ) , $ msg -> getFromUserName ( ) , strtotime ( $ msg -> getCreateTime ( ) ) , $ msg -> getMsgType ( ) , $ msg -> getArticleCount ( ) , $ itemStr ) ; return $ result ; }
formatter WxSendNewsMsg to xml string
@param WxSendNewsMsg $msg
@return string
formatter WxSendNewsMsg to xml string