Getting XML node matching XPath expression - xpath

I'm hoping you can help with this. I tried a number of XPath testers online and wasn't able to find a solution.
I'm trying to get the value of the first node with the '~tid' attribute from this XML:
<Response status="ok" version="1.1">
<Action>
<Page>
<Params>
<Param name="~tid" value="1345811517165"/>
<Param name="~action-type" value="DATA"/>
<Param name="~from-page" value="login"/>
<Param name="~from-act" value="submitData"/>
<Param name="login_USERNAME" value="" type="0"/>
<Param name="login_PASSWORD" value="" type="0"/>
</Params>
</Page>
<Data name="clientData" method="POST">
<Params>
<Param name="timezoneoffset" value=""/>
<Param name="daylightsavings" value=""/>
</Params>
</Data>
</Action>
<Action>
<Page>
<Params>
<Param name="~tid" value="1345811517165"/>
<Param name="~action-type" value="NAV"/>
<Param name="~from-page" value="login"/>
<Param name="~from-act" value="resetPassword"/>
<Param name="~to-page" value="login_resetPassword"/>
</Params>
</Page>
</Action>
<Action>
<Page>
<Params>
<Param name="~tid" value="1345811517165"/>
<Param name="~action-type" value="NAV"/>
<Param name="~from-page" value="login"/>
<Param name="~from-act" value="newUser"/>
<Param name="~to-page" value="login_newUser"/>
</Params>
</Page>
</Action>
</Response>
The XPath I'm using is:
//Params[1]/Param[#name='~tid']/#value
It gets all three values. How can I get just the first one?

Try
/descendant::Params[1]/Param[#name='~tid']/#value
From the W3C XPath specification:
NOTE: The location path //para[1] does not mean the same as the location path /descendant::para[1]. The latter selects the first descendant para element; the former selects all descendant para elements that are the first para children of their parents.

This is the second most FAQ in XPath.
Use:
(//Params/Param[#name='~tid'])[1]/#value
Or even:
(//Param[#name='~tid'])[1]/#value
Explanation:
The XPath pseudo-operator // has lower precedence (priority) than the [] operator.
The usual solution in any laguage when default priority needs to be overriden is to use brackets that explicitly specify the new, wanted priorities.

Related

video conferece mix record in freeswitch

I was configuring Freeswitch to make a video conference. It was normal for everyone to enter the conference ,can watch each other and screen share. but It still existed these problems:
1: conference video record was splited several files that every leg in itself file, but I wanted a mix video that everyone was recorded in one file.how can I configure It?
2:I wanted the screen share is in a fixed position,so I customized conference_layouts.conf.xml and added a new rule.How can I make screen share can be in the floor position,and It screen share not open this postion was empty.
these is my configuration:
dialplan/default.xml
<extension name="my-mcu_conferences">
<condition field="destination_number" expression="^my(\d{5})$">
<action application="export" data="record_concat_video=true"/>
<action application="record_session" data="/freeswitch/recordings/archive/${destination_number}_${strftime(%Y-%m-%d-%H-%M-%S)}.mp4"/>
<action application="answer"/>
<action application="conference" data="$1#my-mcu"/>
</condition>
</extension>
<!-- STEREO 48kHz conferences / Video MCU -->
<extension name="my-mcu-screen_conferences">
<condition field="destination_number" expression="^my(\d{5}).*?-screen$">
<action application="answer"/>
<action application="send_display" data="FreeSWITCH Conference|$1"/>
<!-- I want screen share on the floor -->
<action application="set" data="conference_member_flags=join-vid-floor"/>
<action application="conference" data="$1#my-mcu"/>
</condition>
</extension>
autoload_configs/conference.conf.xml
<profile name="my-mcu">
<param name="domain" value="$${domain}"/>
<param name="rate" value="48000"/>
<param name="channels" value="2"/>
<param name="interval" value="20"/>
<param name="energy-level" value="200"/>
<!-- <param name="tts-engine" value="flite"/> -->
<!-- <param name="tts-voice" value="kal16"/> -->
<param name="muted-sound" value="conference/conf-muted.wav"/>
<param name="unmuted-sound" value="conference/conf-unmuted.wav"/>
<param name="alone-sound" value="conference/conf-alone.wav"/>
<param name="moh-sound" value="$${hold_music}"/>
<param name="enter-sound" value="tone_stream://%(200,0,500,600,700)"/>
<param name="exit-sound" value="tone_stream://%(500,0,300,200,100,50,25)"/>
<param name="kicked-sound" value="conference/conf-kicked.wav"/>
<param name="locked-sound" value="conference/conf-locked.wav"/>
<param name="is-locked-sound" value="conference/conf-is-locked.wav"/>
<param name="is-unlocked-sound" value="conference/conf-is-unlocked.wav"/>
<param name="pin-sound" value="conference/conf-pin.wav"/>
<param name="bad-pin-sound" value="conference/conf-bad-pin.wav"/>
<param name="caller-id-name" value="$${outbound_caller_name}"/>
<param name="caller-id-number" value="$${outbound_caller_id}"/>
<param name="comfort-noise" value="false"/>
<param name="conference-flags" value="livearray-json-status|json-events|video-floor-only|rfc-4579|livearray-sync|minimize-video-encoding|manage-inbound-video-bitrate|video-required-for-canvas|video-mute-exit-canvas|mute-detect"/>
<param name="video-auto-floor-msec" value="1000"/>
<param name="video-mode" value="mux"/>
<param name="video-layout-name" value="1floor_top+4"/>
<!--<param name="video-layout-name" value="group:grid"/>-->
<param name="video-canvas-size" value="1920x1080"/>
<param name="video-canvas-bgcolor" value="#333333"/>
<param name="video-layout-bgcolor" value="#000000"/>
<param name="video-codec-bandwidth" value="3mb"/>
<param name="video-fps" value="30"/>
<!-- <param name="video-codec-config-profile-name" value="conference"/> -->
</profile>
autoload_configs/conference_layouts.conf.xml
<layout name="1floor_top+4">
<image x="45" y="90" scale="270" floor="true" floor-only="true" />
<image x="0" y="0" scale="90" />
<image x="90" y="0" scale="90" />
<image x="180" y="0" scale="90" />
<image x="270" y="0" scale="90" />
</layout>
I have resolved the recording problem by configuring conference.conf.xml adding
<param name="auto-record" value="/freeswitch/recordings/archive/${conference_name}_${strftime(%Y-%m-%d-%H-%M-%S)}.mp4"/>

How to filter messages using Parameter values

I am trying to deselect files based on the value of the param name "filter_param" within the section. Example input file:
<What>
<Param name="filter_param" value="1" />
<Param name="other_param" value="2" />
<Param name="yet_other_param" value="1" />
...
</What>
The 'filter_param' can have any integer value between 1 and 100 and I am trying to get rid of only the ones that have certain values (e.g. 1 and 2). I am trying filters like
"//Param[#name='What/filter_param' and #value!=1] and //Param[#name='What/filter_param' and #value!=2]"
but without success... Any hints?
Use and inside predicates:
//Param[#name="..." and #value != 1 and #value != 2]
If I understand you correctly, assuming your xml looks like this:
<What>
<Param name="filter_param" value="1" />
<Param name="other_param" value="2" />
<Param name="yet_other_param" value="1" />
<Param name="filter_param" value="100" />
</What>
This xpath expression
//What/Param[not(.[#name="filter_param"][#value<3])]
should output:
<Param name="other_param" value="2"/>
<Param name="yet_other_param" value="1"/>
<Param name="filter_param" value="100"/>
Is that what you are looking for?
In XPath 2.0 you can do
//Param[#name="filter_param" and not(#value=(1, 2))]
to select Param node that contains name attribute that equals to "filter_param" and value attribute is not equal to 1, not equal to 2

isVid parameter in Brightcove

Good morning,
does anybody know anything about the purpose of the value: <param name="isVid" value="true" /> in the brightcove player-configuration?
on the website they just say that it's a bool-value and has to be set to "true". Nothing about what it's doing.
The parameter isVid is required when you embbed a video inside an HTML file,
<script language="JavaScript" type="text/javascript" src="
http://admin.brightcove.com/js/BrightcoveExperiences.js"></script>
<object id="myPlayer" class="BrightcoveExperience">
<param name="bgcolor" value="#FFFFFF" />
<param name="width" value="486" />
<param name="height" value="412" />
<param name="playerID" value="1234567890" />
<param name="playerKey" value="AQ~~,AAAAstMe5SE~,5vOZ123456789bOfHyhc1i" />
<param name="isVid" value="true" />
<param name="#videoPlayer" value="ref:myVid12345" />
</object>
I think is not well described on the docs...
isVid: Boolean Required to be true for all video players.
http://support.brightcove.com/en/video-cloud/docs/player-configuration-parameters

How to insert default joomla texteditor in module?

I need to create joomla 1.5 module with textfields wrapped with default texteditor. Could anyone help me, please? Here is my mod_...xml
<params>
<param name="felicitation" type="text" default="Желаем хорошего настроения и счастья:)!" label="Текст поздравления" description="укажите текст поздравления" size="60">
</param>
<param name="message" type="textarea" default="Дорогой друг! От всей души поздравляем тебя с Днём рождения! Желаем благополучия, личностного самосовершенствования, достижения намеченных целей.Сотрудники Центра развития молодёжных волонтёрских программ." cols="30" rows="7" label="Текст письма" description="текст поздравления в письме">
</param>
<param name="image" default="" type="imagelist" label="Выберите картинку" description="" directory="images/stories" >
</param>
</params>
The editor field isn't part of the standard field elements in Joomla 1.5 although it is available in Joomla 2.5 and above.
In your case, you will need to create a custom parameter type. See this response on how to setup a custom field element for the editor.

MVC3 Razor Camtasia Video Embedding, # param Error :-(

Greetings Community!
<object id="myExperienceXXXXXXXX" class="BrightcoveExperience">
<param name="bgcolor" value="#FFFFFF" />
<param name="width" value="448" />
<param name="height" value="251" />
<param name="playerID" value="XXXXXXXXXX" />
<param name="playerKey" value="XXXXXXXXXXX" />
<param name="isVid" value="true" />
<param name="dynamicStreaming" value="true" />
<param name="#videoPlayer" value="XXXXXXXXXXXXX" />
</object>
Notice the last line , I get the following error:
Compiler Error Message: CS0103: The name 'videoPlayer' does not exist in the current context
This value is Required by Camtasia to embed my video in my page. I'm sure there is a simple solution, but I need the "#" sign before the videoPlayer value.
Thanks in advance for any assistance.
# is a reserved character in Razor which should normally be followed by a server side expression. Double it if you want to output it literally:
<param name="##videoPlayer" value="XXXXXXXXXXXXX" />
The # symbol is a reserved character in the Razor view engine. If you want to output a # symbol you can use two # characters to escape the first.
For example:
<param name="##videoPlayer" value="XXXXXXXXXXXXX" />
Not work with the above answers!
It should be the format like this:
<param name="#("#videoPlayer")" value="XXXXXXXXXXXXX" />

Resources