I want extract some information on a website. For this, i use xidel.
I use this command line:
xidel --template-file template.xml --dot-notation=on
and here my template file :
<actions>
<action>
... code before ...
<page url={$url}/>
<pattern>
<div class="row p-r-15 p-l-15 contenu-collec">
{$collection := []}
<t:loop>
{$manga := {}}
<div univers="1">
<div class="post-block collec-titre">
<h2 class="post-title detail-objets">{$manga.title:=.}</h2>
<div>
<input>{$manga.value:=#value}</input>
</div>
</div>
</div>
<!--<call action="test"/>-->
{$collection := $collection.push($manga)}
</t:loop>
</div>
</pattern>
<loop var="t" list="$collection">
<call action="test"/>
</loop>
</action>
<action id="test">
<page url="http://site">
<post name="editions" value="{$t.value}"/>
<post name="action" value="collec_objets_serie"/>
<post name="univers" value="1"/>
<post name="user_id" value="{$userid}"/>
<template>
<!-- <div style="display:block;">{$t.test}</div> -->
<t:loop>
{$t.tome := {}}
<a>{t.tome.url:=#href}</a>
</t:loop>
</template>
</page>
</action>
In the loop i create a object $manga. How to add this object to the $collection array ?
I have tried
{$collection := $collection.push($manga)}
but don't work.
I need to alter my graphs disposal and I have this
{"Modem_Signal_lte0":{"data":[["2017-08-03T07:55:35.000Z",53.1],["2017-08-03T08:00:35.000Z",52.58],["2017-08-03T08:05:35.000Z",52.83],["2017-08-03T08:10:35.000Z",53],["2017-08-03T08:15:35.000Z",53],["2017-08-03T08:20:35.000Z",53],["2017-08-03T08:25:35.000Z",53],["2017-08-03T08:30:35.000Z",54.42],["2017-08-03T08:35:35.000Z",53.05],["2017-08-03T08:40:35.000Z",54.78],["2017-08-03T08:45:35.000Z",55.43],["2017-08-03T08:50:35.000Z",58.55]],"options":{"labels":["Date","rssi"],"showRangeSelector":true,"legend":"always","ylabel":"dBm","title":"Modem Signal","axes":{"y":{}},"width":{}}},"Modem_Roaming_lte0":{"data":[["2017-08-03T07:56:45.000Z",0],["2017-08-03T08:01:45.000Z",0],["2017-08-03T08:06:45.000Z",0],["2017-08-03T08:11:45.000Z",0],["2017-08-03T08:16:45.000Z",0],["2017-08-03T08:21:45.000Z",0],["2017-08-03T08:26:45.000Z",0],["2017-08-03T08:31:45.000Z",0],["2017-08-03T08:36:45.000Z",0],["2017-08-03T08:41:45.000Z",0],["2017-08-03T08:46:45.000Z",0],["2017-08-03T08:51:45.000Z",0]],"options":{"labels":["Date","roaming"],"showRangeSelector":true,"legend":"always","ylabel":"","title":"Modem Roaming","axes":{"y":{}},"width":{}}},"Modem_Activity_lte0":{"data":[["2017-08-03T07:55:35.000Z",1],["2017-08-03T08:00:35.000Z",1],["2017-08-03T08:05:35.000Z",1],["2017-08-03T08:10:35.000Z",1],["2017-08-03T08:15:35.000Z",0.98],["2017-08-03T08:20:35.000Z",1],["2017-08-03T08:25:35.000Z",1],["2017-08-03T08:30:35.000Z",1],["2017-08-03T08:35:35.000Z",1],["2017-08-03T08:40:35.000Z",0.98],["2017-08-03T08:45:35.000Z",1],["2017-08-03T08:50:35.000Z",0.98]],"options":{"labels":["Date","state"],"showRangeSelector":true,"legend":"always","ylabel":"","title":"Modem Activity","axes":{"y":{}},"width":{}}},"Modem_Mode_lte0":{"data":[["2017-08-03T07:55:35.000Z",6],["2017-08-03T08:00:35.000Z",6],["2017-08-03T08:05:35.000Z",6],["2017-08-03T08:10:35.000Z",6],["2017-08-03T08:15:35.000Z",6],["2017-08-03T08:20:35.000Z",6],["2017-08-03T08:25:35.000Z",6],["2017-08-03T08:30:35.000Z",6],["2017-08-03T08:35:35.000Z",6],["2017-08-03T08:40:35.000Z",6],["2017-08-03T08:45:35.000Z",6],["2017-08-03T08:50:35.000Z",6]],"options":{"labels":["Date","Sysmode"],"showRangeSelector":true,"legend":"always","ylabel":"","title":"Modem Mode","axes":{"y":{"includeZero":true}},"width":{}}}}
And then it presents four graphs "Modem Activity", "Modem Mode", "Modem Roaming" and "Modem Signal".
I need to switch the graph "Modem Roaming" with "Modem Signal".
How to do this?
My view:
<tab heading="Modems" select="changeTab()" disable="!tabClick" active="activeTab.modem">
<div class="no-data" ng-if="activeNoData.modem">
<img src="/assets/img/nodata.png"/>
<h3>No Data</h3>
</div>
<tabset class="box-tab box-tab-sub">
<tab ng-repeat="type in dataGraph.modem.types" heading="{{type.label}}" select="changeSubTab(type.type)" disable="!tabClick">
<p>{{dataGraph.modem[type.type]}}</p>
<div class="col-md-12" style="text-align:center;margin-bottom:30px" ng-repeat="graph in dataGraph.modem[type.type]">
<img ng-if="!graph.options" style="height:32px;margin:50px auto;" src="/assets/img/loader.gif" />
<div ng-if="graph.options">
<dygraph options='graph.options' data="graph.data"></dygraph><br>
</div>
</div>
</tab>
</tabset>
</tab>
The sequence of key in an object is not guaranteed. You need to reorganize them into array if you care about the sequence.
var data = // data here
var dataArr = [];
dataArr.push(data.Modem_Activity_lte0);
dataArr.push(data.Modem_Mode_lte0);
dataArr.push(data.Modem_Roaming_lte0);
dataArr.push(data.Modem_Signal_lte0);
I'm using Angular-Ui Bootstrap Tabset for AngularJS. I have 8 different tabs and all of them run a function when clicked. The activated tab is defined on the controller based on the object properties. The code is like this:
<tabset ng-if="paginaPronta">
<tab heading="Histórico" active="activeTabs.historico" disabled="beforeNew" select="tabHistorico('html')">
<div ng-include="includes.historico" class="row padding0"></div>
</tab>
<tab heading="Pedido" active="activeTabs.pedido" select="tabPedido('html')">
<div ng-include="includes.pedido" class="row padding0"></div>
</tab>
<tab heading="Documentos" active="activeTabs.documentos" disabled="beforeNew" select="tabDocumentos('html')">
<div ng-include="includes.documentos" class="row padding0"></div>
</tab>
<tab heading="Posse" active="activeTabs.posse" disabled="beforeNew" select="tabPosse('html')">
<div ng-include="includes.posse"></div>
</tab>
<tab heading="Despesas" active="activeTabs.despesas" disabled="beforeNew" select="tabDespesas('html')">
<div ng-include="includes.despesas" class="row padding0"></div>
</tab>
<tab heading="Faturação" active="activeTabs.faturacao" select="tabFaturacao('html')">
<div ng-include="includes.faturacao" class="row padding0"></div>
</tab>
<tab heading="Anexos" select="tabAnexos('html')">
<div ng-include="includes.anexos" class="row padding0"></div>
</tab>
<tab heading="Relatório" active="activeTabs.relatorio" disabled="beforeNew" select="tabRelatorio('html')">
<div ng-include="includes.relatorio"></div>
</tab>
</tabset>
Everything works fine at beginning but, when I change the location to navigate to another page, all 8 tab functions are called (tabHistorico(), tabPedido(), tabPosse()...)
I'm not calling the functions in any other place, I put the 'html' in every function and them made a console.log('tabHistorico: ' + phrase) on the controller and it gets printted tabHistorico: html. So, I know that all tabs are activated, I can't figure out why...
I'm trying to get nested tabsets. But there's a problem - the nested tabset doesn't work because of TypeError: Cannot read property '$parent' of undefined
You can see it here:
http://plnkr.co/edit/xU9RibIL9k1D3m4GwB5z?p=preview
The html part (most important, controller is empty)
<tabset>
<tab heading="normal">
<div>Content 1</div>
</tab>
<tab heading="nested">
<div>
<tabset>
<tab heading="Nested One">
<div>Nested Content 1</div>
</tab>
<tab heading="Nested Two">
<div>Nested Content 2</div>
</tab>
</tabset>
</div>
</tab>
</tabset>
(And no, I can't use ng-view and routing - because I don't want to lost contents of tabs when switched back - routing reloads tab content)
I'm working on parsing XML documents using SQL Server 2008. I'm a complete noob and I was wondering if I can get help from you guys.
I have an XML document like the one below and I want to get the "section" node where the "code" node has val=5.
<root>
<section>
<code val=6 />
...
</section>
<section>
<code val=5 />
...
</section>
<section>
<code val=4 />
...
</section>
</root>
So the result should be:
<section>
<code val=5 />
...
</section>
I tried doing this, but it didn't work:
select #xml.query('/root/section')
where #xml.value('/root/section/code/#val,'int')= '5'
I also tried this:
select #xml.query('/root/section')
where #xml.exist('/root[1]/section[1]/code[#val="1"])= '1'
Any ideas? Thanks in advance.
You could use this query:
DECLARE #x XML=N'
<root>
<section atr="A">
<code val="5" />
</section>
<section atr="B">
<code val="6" />
</section>
<section atr="C">
<code val="5" />
</section>
</root>';
SELECT a.b.query('.') AS SectionAsXmlElement,
a.b.value('#atr','NVARCHAR(50)') AS SectionAtr
FROM #x.nodes('/root/section[code/#val="5"]') a(b);
Results:
SectionAsXmlElement SectionAtr
------------------------------------------- ----------
<section atr="A"><code val="5" /></section> A
<section atr="C"><code val="5" /></section> C
Instead of where you can apply the constraint in an XPath predicate:
#xml.query('/root/section[code/#val=5]')