Note that there are some explanatory texts on larger screens.

plurals
  1. POBest way to remove remove values from variable? create an array, or using regex? or with Xpath?
    primarykey
    data
    text
    <p>Im trying to extract some fields from the output at the end of this question with the following code:</p> <pre><code>doc = LH.fromstring(html2) tds = (td.text_content() for td in doc.xpath("//td[not(*)]")) for a,b,c in zip(*[tds]*3): print (a,b,c) </code></pre> <p>What i expect is to extract only the fields notificationNodeName,notificationNodeName,packageName,notificationEnabled </p> <p>The main problem with that is because i want to put the result into a database. and i need to, instead receiveing:</p> <p>Actual code returns:</p> <pre><code>('JDBCAdapter', 'JDBCAdapter', 'Package:Notif') ('Package', 'yes', 'Package_2:Notif') ('Package_2', 'yes') </code></pre> <p>What i need:</p> <pre><code>('Package:Notif','Package', 'yes') ('Package_2:Notif','Package_2', 'yes') </code></pre> <p>An unly solution that i found was:</p> <pre><code>doc = LH.fromstring(html2) tds = (td.text_content() for td in doc.xpath("//td")) for td, val in zip(*[tds]*2): if td == 'notificationNodeName': notificationNodeName = val elif td == 'packageName': packageName = val elif td == 'notificationEnabled': notificationEnabled = val print (notificationNodeName,packageName,notificationEnabled) </code></pre> <p>It works but doenst seen right for me, im sure it can be a better way to do it.</p> <p>Original HTML Output:</p> <pre><code>&lt;tbody&gt;&lt;tr&gt; &lt;td valign="top"&gt;&lt;b&gt;adapterTypeName&lt;/b&gt;&lt;/td&gt; &lt;td&gt;JDBCAdapter&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td valign="top"&gt;&lt;b&gt;adapterTypeNameList&lt;/b&gt;&lt;/td&gt; &lt;td&gt; &lt;table&gt; &lt;tbody&gt;&lt;tr&gt; &lt;td&gt;JDBCAdapter&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td valign="top"&gt;&lt;b&gt;notificationDataList&lt;/b&gt;&lt;/td&gt; &lt;td&gt; &lt;table&gt; &lt;tbody&gt;&lt;tr&gt; &lt;td&gt;&lt;table bgcolor="#dddddd" border="1"&gt; &lt;tbody&gt;&lt;tr&gt; &lt;td valign="top"&gt;&lt;b&gt;notificationNodeName&lt;/b&gt;&lt;/td&gt; &lt;td&gt;package:Notif&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td valign="top"&gt;&lt;b&gt;packageName&lt;/b&gt;&lt;/td&gt; &lt;td&gt;Package&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td valign="top"&gt;&lt;b&gt;notificationEnabled&lt;/b&gt;&lt;/td&gt; &lt;td&gt;unsched&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;table bgcolor="#dddddd" border="1"&gt; &lt;tbody&gt;&lt;tr&gt; &lt;td valign="top"&gt;&lt;b&gt;notificationNodeName&lt;/b&gt;&lt;/td&gt; &lt;td&gt;Package_2:notif&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td valign="top"&gt;&lt;b&gt;packageName&lt;/b&gt;&lt;/td&gt; &lt;td&gt;package_2&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td valign="top"&gt;&lt;b&gt;notificationEnabled&lt;/b&gt;&lt;/td&gt; &lt;td&gt;yes&lt;/td&gt; &lt;/tr&gt; and continues to more ... non relevant repetitive data. </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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