Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/397.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用jquery.find查找XML元素会产生意外的结果_Javascript_Jquery_Xml_Xml Parsing - Fatal编程技术网

Javascript 使用jquery.find查找XML元素会产生意外的结果

Javascript 使用jquery.find查找XML元素会产生意外的结果,javascript,jquery,xml,xml-parsing,Javascript,Jquery,Xml,Xml Parsing,我使用jquery帮助从sharepoint服务提取信息,但由于某些原因,某些元素无法找到,而其他元素可以 以下是XML字符串: <?xml version="1.0" encoding="utf-8"?><entry xml:base="https://geosolutionsnetau.sharepoint.com/Residential/_api/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.m

我使用jquery帮助从sharepoint服务提取信息,但由于某些原因,某些元素无法找到,而其他元素可以

以下是XML字符串:

<?xml version="1.0" encoding="utf-8"?><entry xml:base="https://geosolutionsnetau.sharepoint.com/Residential/_api/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml" m:etag="&quot;7&quot;"><id>747741d3-6f71-424b-898a-3138c285edf5</id><category term="SP.Data.CustomersListItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /><link rel="edit" href="Web/Lists(guid'bf1cef04-e377-4f25-824c-0626557af1ab')/Items(5)" /><title /><updated>2017-07-23T01:59:21Z</updated><author><name /></author><content type="application/xml"><m:properties><d:Company_x0020_Name>Wilson Homes</d:Company_x0020_Name></m:properties></content></entry>
它正确地返回一个元素,但是当试图查找名为“Company_x0020_Name”的元素时,它什么也找不到。XML的格式似乎正确,所以我不知道为什么它找不到一些元素,但可以找到其他元素

这是在Firefox中,发出的完整jquery请求如下:

$.get( url, function( data ) {
    var xmlElement = $(data).find(fieldName);
    var text = xmlElement.text();
});

HTML缺少起始
标记。您能澄清一下您的意思吗@Guest271314 XML仅包含结束标记,但不包含开始标记。XML格式不正确。谢谢。我想知道为什么SharePoint返回格式不正确的XML。
$.get( url, function( data ) {
    var xmlElement = $(data).find(fieldName);
    var text = xmlElement.text();
});