Note that there are some explanatory texts on larger screens.

plurals
  1. POxml.parse return null google app script
    text
    copied!<p>I am trying parse the xml but result return <code>null</code>.</p> <p>Here is the xml:</p> <pre><code>&lt;feed&gt; &lt;title type="text"&gt;neymar&lt;/title&gt; &lt;subtitle type="text"&gt;Bing Image Search&lt;/subtitle&gt; &lt;id&gt;https://api.datamarket.azure.com/Data.ashx/Bing/Search/Image?Query='neymar'&amp;$top=2&lt;/id&gt; &lt;rights type="text"/&gt; &lt;updated&gt;2013-05-13T08:45:02Z&lt;/updated&gt; &lt;link rel="next" href="https://api.datamarket.azure.com/Data.ashx/Bing/Search/Image?Query='neymar'&amp;$skip=2&amp;$top=2"/&gt; &lt;entry&gt; &lt;id&gt;https://api.datamarket.azure.com/Data.ashx/Bing/Search/Image?Query='neymar'&amp;$skip=0&amp;$top=1&lt;/id&gt; &lt;title type="text"&gt;ImageResult&lt;/title&gt; &lt;updated&gt;2013-05-13T08:45:02Z&lt;/updated&gt; &lt;content type="application/xml"&gt; &lt;m:properties&gt; &lt;d:ID m:type="Edm.Guid"&gt;99cb00e9-c9bb-45ca-9776-1f51e30be398&lt;/d:ID&gt; &lt;d:Title m:type="Edm.String"&gt;neymaer wallpaper neymar brazil wonder kid neymar wallpaper hd&lt;/d:Title&gt; &lt;d:MediaUrl m:type="Edm.String"&gt;http://3.bp.blogspot.com/-uzJS8HW4j24/Tz3g6bNII_I/AAAAAAAAB1o/ExYxctnybUo/s1600/neymar-wallpaper-5.jpg&lt;/d:MediaUrl&gt; &lt;d:SourceUrl m:type="Edm.String"&gt;http://insidefootballworld.blogspot.com/2012/02/neymar-wallpapers.html&lt;/d:SourceUrl&gt; &lt;d:DisplayUrl m:type="Edm.String"&gt;insidefootballworld.blogspot.com/2012/02/neymar-wallpapers.html&lt;/d:DisplayUrl&gt; &lt;d:Width m:type="Edm.Int32"&gt;1280&lt;/d:Width&gt; &lt;d:Height m:type="Edm.Int32"&gt;800&lt;/d:Height&gt; &lt;d:FileSize m:type="Edm.Int64"&gt;354173&lt;/d:FileSize&gt; &lt;d:ContentType m:type="Edm.String"&gt;image/jpeg&lt;/d:ContentType&gt; &lt;d:Thumbnail m:type="Bing.Thumbnail"&gt; &lt;d:MediaUrl m:type="Edm.String"&gt;http://ts3.mm.bing.net/th?id=H.5042206689331494&amp;pid=15.1&lt;/d:MediaUrl&gt; &lt;d:ContentType m:type="Edm.String"&gt;image/jpg&lt;/d:ContentType&gt; &lt;d:Width m:type="Edm.Int32"&gt;300&lt;/d:Width&gt; &lt;d:Height m:type="Edm.Int32"&gt;187&lt;/d:Height&gt; &lt;d:FileSize m:type="Edm.Int64"&gt;12990&lt;/d:FileSize&gt; &lt;/d:Thumbnail&gt; &lt;/m:properties&gt; &lt;/content&gt; &lt;/entry&gt; &lt;entry&gt; &lt;id&gt;https://api.datamarket.azure.com/Data.ashx/Bing/Search/Image?Query='neymar'&amp;$skip=1&amp;$top=1&lt;/id&gt; &lt;title type="text"&gt;ImageResult&lt;/title&gt; &lt;updated&gt;2013-05-13T08:45:02Z&lt;/updated&gt; &lt;content type="application/xml"&gt; &lt;m:properties&gt; &lt;d:ID m:type="Edm.Guid"&gt;9a6b7476-643e-4844-a8da-a4b640a78339&lt;/d:ID&gt; &lt;d:Title m:type="Edm.String"&gt;neymar jr 485x272 Neymar Show 2012 Hd&lt;/d:Title&gt; &lt;d:MediaUrl m:type="Edm.String"&gt;http://www.sontransferler.com/wp-content/uploads/2012/07/neymar_jr.jpg&lt;/d:MediaUrl&gt; &lt;d:SourceUrl m:type="Edm.String"&gt;http://www.sontransferler.com/neymar-show-2012-hd&lt;/d:SourceUrl&gt; &lt;d:DisplayUrl m:type="Edm.String"&gt;www.sontransferler.com/neymar-show-2012-hd&lt;/d:DisplayUrl&gt; &lt;d:Width m:type="Edm.Int32"&gt;1366&lt;/d:Width&gt; &lt;d:Height m:type="Edm.Int32"&gt;768&lt;/d:Height&gt; &lt;d:FileSize m:type="Edm.Int64"&gt;59707&lt;/d:FileSize&gt; &lt;d:ContentType m:type="Edm.String"&gt;image/jpeg&lt;/d:ContentType&gt; &lt;d:Thumbnail m:type="Bing.Thumbnail"&gt; &lt;d:MediaUrl m:type="Edm.String"&gt;http://ts1.mm.bing.net/th?id=H.4796985557255960&amp;pid=15.1&lt;/d:MediaUrl&gt; &lt;d:ContentType m:type="Edm.String"&gt;image/jpg&lt;/d:ContentType&gt; &lt;d:Width m:type="Edm.Int32"&gt;300&lt;/d:Width&gt; &lt;d:Height m:type="Edm.Int32"&gt;168&lt;/d:Height&gt; &lt;d:FileSize m:type="Edm.Int64"&gt;4718&lt;/d:FileSize&gt; &lt;/d:Thumbnail&gt; &lt;/m:properties&gt; &lt;/content&gt; &lt;/entry&gt; &lt;/feed&gt; </code></pre> <p>and here is the code:</p> <pre><code>var response = UrlFetchApp.fetch('https://api.datamarket.azure.com/Bing/Search/Image?Query=%27neymar%27&amp;$top=2',options) var resp = response.getContentText(); var ggg = Xml.parse(resp,false).getElement().getElement('entry').getElement('content').getElement('m:properties'); Logger.log(ggg); </code></pre> <p>How do I get element <code>&lt;d:MediaUrl m:type="Edm.String"&gt;</code>?</p> <blockquote> <p>update: but still not work</p> </blockquote> <pre><code>var response = UrlFetchApp.fetch('https://api.datamarket.azure.com/Bing/Search/Image?Query=%27neymar%27&amp;$top=2',options) var text = response.getContentText(); var eleCont = Xml.parse(text,true).getElement().getElement('entry').getElement('content'); var eleProp = eleCont.getElement('hxxp://schemas.microsoft.com/ado/2007/08/dataservices/metadata','properties') var medUrl= eleProp.getElement('hxxp://schemas.microsoft.com/ado/2007/08/dataservices','MediaUrl').getText() Logger.log(medUrl) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload