# xpath help

**URL:** <https://forums.plex.tv/t/xpath-help/60699>\
**Category:** Dev/API Corner\
**Tags:** plugin-dev\
**Created:** [March 18, 2014, 3:29am UTC](https://forums.plex.tv/t/xpath-help/60699 "2014-03-18T03:29:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lexy](https://avatars.discourse-cdn.com/v4/letter/l/f475e1/32.png) [@Lexy](https://forums.plex.tv/u/Lexy)\
**Post date:** [March 18, 2014, 3:29am UTC](https://forums.plex.tv/t/xpath-help/60699/1 "2014-03-18T03:29:20Z")

</div>

Hi,

&nbsp;

I am working on making a channel for a website that uses the Brightcove service. I need to get the values of the vars playerID, playerKey, and @videoPlayer. I have no problem getting playerID and playerKey, but @videoPlayer throws an error. If I hardcode the expected value, I get no error and everything is fine. So I assume it is something to do with the @ symbol. Does anyone have any suggestions to work around this?

```
###################################################################################################
@route(PREFIX + '/showdocs')
def ShowDocs(title, pass_url):

&nbsp;&nbsp;&nbsp; #documentary level  
&nbsp;&nbsp;&nbsp; oc = ObjectContainer(title2=title)  
&nbsp;&nbsp;&nbsp; docElement = HTML.ElementFromURL(pass\_url)  
&nbsp;&nbsp;&nbsp; docTitle = docElement.xpath(’//h1[@class=“title”]’)[0].text  
&nbsp;&nbsp;&nbsp; docSummary = docElement.xpath(’//head//meta[@property=“og:description”]’)[0].get(‘content’)  
&nbsp;&nbsp;&nbsp; #VideoID = ‘2252754546001’  
&nbsp;&nbsp;&nbsp; VideoID = docElement.xpath(’//param[contains(@name, “@videoPlayer”)]’)[0].get(‘value’)  
&nbsp;&nbsp;&nbsp; PlayerID = docElement.xpath(’//param[contains(@name, “playerID”)]’)[0].get(‘value’)  
&nbsp;&nbsp;&nbsp; PlayerKey = docElement.xpath(’//param[contains(@name, “playerKey”)]’)[0].get(‘value’)  
&nbsp;&nbsp;&nbsp; vidURL = ‘[http://c.brightcove.com/services/viewer/federated\_f9?isVid=1&isUI=1&videoId=’+VideoID+’&playerID=’+PlayerID+’&playerKey=’+PlayerKey+’&domain=embed&dynamicStreaming=true](http://c.brightcove.com/services/viewer/federated_f9?isVid=1&isUI=1&videoId='+VideoID+'&playerID='+PlayerID+'&playerKey='+PlayerKey+'&domain=embed&dynamicStreaming=true)’

&nbsp;&nbsp;&nbsp; #menu level  
&nbsp;&nbsp;&nbsp; oc.add(VideoClipObject(title = docTitle, url = vidURL, summary = docSummary))  
&nbsp;&nbsp;&nbsp; return oc
```

- HTML/Javascript snippet from webpage

&nbsp;

document.write('');  
document.write('');  
document.write('');  
document.write('');  
document.write('');  
document.write('');  
document.write('');

---

<div class="post-metadata">

**Author:** ![mikedm139](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/mikedm139/32/96909_2.png) [@mikedm139](https://forums.plex.tv/u/mikedm139)\
**Post date:** [March 18, 2014, 3:40am UTC](https://forums.plex.tv/t/xpath-help/60699/2 "2014-03-18T03:40:55Z")

</div>

Seems like you’re trying to use xpath on HTML which is loaded dynamically via javascript when the page loads. That won’t work since the channel framework won’t execute the javascript. Since the javascript is actually contained in the page source, you can parse it as text using regex instead.

```
RE_VIDEOPLAYER = Regex(’’)

…  
data = HTTP.Request(page\_url).content  
player = RE\_VIDEOPLAYER.search(data).group(1)
```

---

<div class="post-metadata">

**Author:** ![Lexy](https://avatars.discourse-cdn.com/v4/letter/l/f475e1/32.png) [@Lexy](https://forums.plex.tv/u/Lexy)\
**Post date:** [March 18, 2014, 4:04am UTC](https://forums.plex.tv/t/xpath-help/60699/3 "2014-03-18T04:04:56Z")

</div>

Thank you Mikedm139! That did the trick. Would you recommend that I use regex on the other 2 vars as well even though I am able to use xpath to get their values? Does it matter?&nbsp;

---

<div class="post-metadata">

**Author:** ![mikedm139](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/mikedm139/32/96909_2.png) [@mikedm139](https://forums.plex.tv/u/mikedm139)\
**Post date:** [March 18, 2014, 1:09pm UTC](https://forums.plex.tv/t/xpath-help/60699/4 "2014-03-18T13:09:30Z")

</div>

I probably doesn’t matter.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)\
**Post date:** [December 21, 2019, 1:35am UTC](https://forums.plex.tv/t/xpath-help/60699/5 "2019-12-21T01:35:35Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
