如何使用java解析从Sharepoint表单提交生成的XML?

时间:2014-09-24 05:48:07

标签: java sharepoint jaxb infopath

我有一个要求,请求者将使用sharepoint提交信息路径表单,如何解析XML文件并使用java提取值? 请给出建议? 我尝试了以下代码。

 import java.io.File;

 import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;    
import javax.xml.bind.Unmarshaller;
public class feedToobject {

public static void main(String[] args) {
    // TODO Auto-generated method stub

    File file=new File("C:\\file1.xml");
    try {
        JAXBContext jb=JAXBContext.newInstance(FeedProvisioning.class);
        Unmarshaller um=jb.createUnmarshaller();
        FeedProvisioning feed=(FeedProvisioning) um.unmarshal(file);

        System.out.println(feed.getRequestor_email());
        System.out.println(feed.requestor_email);


    } catch (JAXBException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }


}


}

但是得到错误  “javax.xml.bind.UnmarshalException:意外元素(uri:”http://schemas.microsoft.com/office/infopath/2003/myXSD/2014-05-29T10:32:58“,local:”xferRequestFields“)。预期元素是(无)     at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(Unknown Source)“

我的xml文件如下。

    <?xml version="1.0" encoding="UTF-8"?>
    <?mso-infoPathSolution solutionVersion="1.0.0.97" PIVersion="1.0.0.0"                       href="file:///\\s3\4thline\Clients\lpop\Project\Service%20Design\Project%20Transfer%20Request%20Form%203.01.xsn" name="urn:schemas-microsoft-com:office:infopath:Project-Transfer-Request-Form-0-5-1:-    myXSD-2014-05-29T10-32-58" productVersion="15.0.0" ?>
    <?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.3"?>     <my:xferRequestFields my:xferArchitectEmail="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xmlns:pc="http://schemas.microsoft.com/office/infopath/2007/PartnerControls" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2014-05-29T10:32:58" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="en-us">
   <my:reqName>Sushma</my:reqName>
  <my:reqEmail>sushma@cnk.com</my:reqEmail>

由于 sushma。

0 个答案:

没有答案