我必须解析外部提供的XML,该XML具有包含换行符的属性.使用SimpleXML,换行似乎丢失了.根据另一个stackoverflow问题,换行符应该对XML有效(即使远远不够理想!).
他们为什么输了?[编辑] 我怎样才能保存它们?[/编辑]
这是一个演示文件脚本(请注意,当换行符不在属性中时,它们会被保留).
带嵌入式XML的PHP文件
$xml = <<<XML
<?xml version="1.0" encoding="utf-8"?>
<Rows>
<data Title='Data Title' Remarks='First line of the row.
Followed by the second line.
Even a third!' />
<data Title='Full Title' Remarks='None really'>First line of the row.
Followed by the second line.
Even a third!</data>
</Rows>
XML;
$xml = new SimpleXMLElement( $xml );
print '<pre>'; print_r($xml); print '</pre>';
Run Code Online (Sandbox Code Playgroud)
print_r的输出
SimpleXMLElement Object
(
[data] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Title] …Run Code Online (Sandbox Code Playgroud) 我做了什么
什么是工作
现在,当我使用该模板在SharePoint中创建一个新的List时,它可以完美地运行.存在自定义列,并且数据全部按预期填充.
什么不工作
但是,当我使用SharePoint Web服务提供的AddList或AddListFromFeature方法时,会创建新列表,但它只是基于原始Project Tasks模板,具有默认列且没有数据!
我试过的
系统设置
使用SharePoint 2007(我认为?),使用PHP与NuSOAP进行连接.连接肯定有效,因为我已经将项目添加到列表,创建列表和读取数据.
代码示例
请求 - 针对上面的阶段2方法模板
<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2034="http://tempuri.org"><SOAP-ENV:Body>
<AddListFromFeature xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<listName>2Test Milestone Release</listName>
<description>Testing this out</description>
<featureID>{00BFEA71-513D-4CA0-96C2-6A47775C0119}</featureID>
<templateID>151</templateID>
</AddListFromFeature></SOAP-ENV:Body></SOAP-ENV:Envelope>
Run Code Online (Sandbox Code Playgroud)
响应 - 由于未识别templateID而失败
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.</faultstring><detail><errorstring xmlns="http://schemas.microsoft.com/sharepoint/soap/">Cannot complete this action.
Please try again.</errorstring><errorcode xmlns="http://schemas.microsoft.com/sharepoint/soap/">0x81072101</errorcode></detail></soap:Fault></soap:Body></soap:Envelope>
Run Code Online (Sandbox Code Playgroud)
我很难过!所以,如果你能提供帮助 …
我试图向优化90GB +表迈出一步:
旧表
桌子每天抓住大约.来自外部源的750,000条记录,并使用新日期将它们添加到表中.根据我的理解,这已经持续了三年.97%的记录从一天到下一天都没有变化.
新表
我试图通过旧表(数以百万计的记录)并消除冗余,这可能会极大地减少表的大小.
OLD_TABLE
new_table_index
NEW_TABLE
我们遍历old_table中的每条记录时的逻辑
if(record_id不在new_table中)或(record_id在new_table中,但最新的条目有不同的data_field)
将其插入new_table并获取index_id
其他
从new_table_index获取该record_id的最新条目index_id
总是
将index_id和date插入new_table_index
有关最佳方法的任何想法吗?我没有足够先进的MySQL将这一切放在一起.当我尝试用PHP编写脚本时,它耗尽了3GB内存然后失败了.其他建议或疑问??? 非常感谢!