【发布时间】:2013-09-12 06:39:11
【问题描述】:
<?xml version="1.0" encoding="utf-8"?>
<?mso-infoPathSolution name="urn:schemas-microsoft-com:office:infopath:TestCRForm:-myXSD-2013-01-09T15-23-27" solutionVersion="1.0.0.285" productVersion="14.0.0.0" PIVersion="1.0.0.0" href="http://win-rskupn6mf2b:2331/TestCRForm/Forms/template.xsn"?>
<?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.3"?>
<my:myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pc="http://schemas.microsoft.com/office/infopath/2007/PartnerControls" xmlns:ma="http://schemas.microsoft.com/office/2009/metadata/properties/metaAttributes" xmlns:d="http://schemas.microsoft.com/office/infopath/2009/WSSList/dataFields" xmlns:q="http://schemas.microsoft.com/office/infopath/2009/WSSList/queryFields" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:dms="http://schemas.microsoft.com/office/2009/documentManagement/types" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:tns="http://microsoft.com/webservices/SharePointPortalServer/UserProfileService" xmlns:s1="http://microsoft.com/wsdl/types/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2013-01-09T15:23:27" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="en-US">
<my:VendorName>Vendor Name1</my:VendorName>
<my:Assignedto>Asigner</my:Assignedto>
<my:SOWNumber></my:SOWNumber>
<my:DraftStarted xsi:nil="true"></my:DraftStarted>
<my:DateComplete xsi:nil="true"></my:DateComplete>
<my:GLCode>Material No1</my:GLCode>
<my:LogID>2013-09-05T22:44:09</my:LogID>
<my:Status>New</my:Status>
<my:ProjectDescription>
<html xmlns="http://www.w3.org/1999/xhtml" xml:space="preserve">
<p> THIS TEXT</p>
</html>
</my:ProjectDescription>
</my:myFields>
我可以访问标签内的字段:VendorName & AssignedTo 使用以下
XmlNodeList nodelist1 = xml.GetElementsByTagName("my:myFields");
foreach (XmlNode node in nodelist1)
text_name = node["my:VendorName"].InnerText;
但我无法访问 ProjectDescription 标记内的内部文本,即使用“THIS TEXT”
XmlNodeList nodelist1 = xml.GetElementsByTagName("my:myFields/my:ProjectDescription/html");
foreach (XmlNode node in nodelist1)
text1 = node["p"].InnerText;
在调试模式下运行时,我在 nodelist1 中得到 NULL。
请给我建议一种方法来做到这一点。
【问题讨论】:
-
我认为 my:myFields/my:ProjectDescription/html 的语法不正确。尝试单独获取它。看看这个:bytes.com/topic/net/answers/…
-
我已经尝试过另一个没有命名空间的简单 xml 文件,它工作正常。与名称空间有关,但我无法准确弄清楚。
标签: c# xml sharepoint-2010 infopath2010