I am trying to all p elements located between two h5 elements. The starting h5 text is "Subject" and the second h5 text is "tenders file".
You may see the picture attached as well.
I don't want to have other p elements which are coming after the second h5.
I have tried the following XPath:
//p[preceding-sibling::h5//*[contains(text() , 'SUBJECT')] and following-sibling::h5//*[contains(text() , 'Tender’s Files,')]] trying to get idea from [enter link description here][2]
but could not get the right paragraphs. It still selects other paragraphs after the second h5.
<div>
<table class="table table-striped table-bordered table-hover" width="90%">
<tbody>
<tr>
<td style="vertical-align: middle;" colspan="2" width="90%">
<h5 style="padding-left: 10px;"><strong><span style="color: #3577be;">Tender Title:</span> Testing of Non-Fortified Wheat Flour in NES</strong></h5>
</td>
</tr>
<tr>
<td style="vertical-align: middle;" width="45%">
<h5 style="padding-left: 10px;"><strong><span style="color: #3577be;">Tender No:</span> SYRIA-TA-2021-005</strong></h5>
</td>
<td style="vertical-align: middle;">
<h5 style="padding-left: 10px;"><strong><span style="color: #3577be;">Location:</span> North East Syria</strong></h5>
</td>
</tr>
<tr>
<td style="vertical-align: middle;" colspan="2">
<h5 style="padding-left: 10px;"><strong><span style="color: #3577be;">Tender Package Available from:</span> 2021-01-10</strong></h5>
</td>
</tr>
<tr>
<td style="vertical-align: middle;" colspan="2">
<h5 style="padding-left: 10px;"><strong><span style="color: #3577be;">Deadline for Offer Submission:</span> 2021-01-18 17:00 (Iraqi Time)</strong></h5>
</td>
</tr>
</tbody>
</table>
<table class="table " width="90%">
<tbody>
<tr>
<td style="text-align: center;"> </td>
</tr>
</tbody>
</table>
<h5><strong><u>SUBJECT:</u></strong> <strong>Testing of Non-Fortified Wheat Flour in NES</strong></h5>
<p>Our organization, a non-profit organization, provides humanitarian assistance to “people in need”, is seeking quotations from eligible contractors to <strong>Testing of Non-Fortified Wheat Flour in NES</strong>. Our organization anticipates awarding Multiple or Single contract(s) as a result of this Solicitation. Our organization reserves the right to award more or none under this RFQ.</p>
<p>All bids shall be submitted <strong>via e-mail to</strong> <span id="cloak1f9ac73a082c1f52174ccee4f406b81c"><strong>Syr-tendering#blumont.org</strong></span> <strong>as PDF format and clearly written the subject of the tender</strong> This RFQ is in no way obligates our organization Our organization to award a contract nor does it commit our organization to pay any cost incurred in the preparation and submission of a proposal.</p>
<p>Our organization bears no responsibility for data errors resulting from transmission or conversion processes.</p>
<p> </p>
<ul>
<li><strong>To help us with our procurement effort, please indicate in your email where (ngotenders.net) you saw this tender/procurement notice.</strong></li>
</ul>
<p><strong>Sincerely</strong></p>
<p><strong>Procurement Committee</strong></p>
<h5><strong>Tender’s Files,</strong></h5>
<h5><strong>5ffb04ba52a49-005-announcement.zip, </strong></h5>
<hr>
<h5 dir="rtl"><strong><u>الموضوع</u></strong><strong><u>:</u></strong> <strong>فحص الطحين الغير مدعم في شمال شرق سوريا.</strong><strong> </strong></h5>
<p dir="rtl">منظمتنا و هي منظمة غير ربحية تعمل لخدمة المنكوبين في العالم و تسعى للحصول على عروض أسعار من المقاولين المؤهلين لغرض الموضوع: <strong>فحص الطحين الغير مدعم في شمال شرق سوريا.</strong> وتتوقع منظمتنا منح (عقود) متعددة أو مفردة نتيجة لهذا الطلب. وتحتفظ منظمتنا بالحق في منح التعاقد بأكثر أو أقل من المتوقع للطلب أعلاه.</p>
<p dir="rtl">لهذا الطلب. وتحتفظ منظمتنا بالحق في منح التعاقد بأكثر أو أقل من المتوقع للطلب أعلاه.</p>
<p dir="rtl"> يجب على جميع مقدمي العطاءات تقديم العروض عبر الايميل :<strong>عبر الايميل: </strong><span id="cloakc42a61e471daa10a7992dbd8b44f9b26"><strong>Syr-tendering#blumont.org</strong></span> <strong>و بصيغة</strong><strong> PDF</strong> و تم التوضيح للموضوع المناقصة بان المنظمة لا تلتزم بأي حال من الأحوال بمنح العقد كما أن المنظمة لا تلتزم بدفع أي تكاليف متكبدة في إعداد وتقديم العرض.</p>
<p dir="rtl">كما ان منظمتنا لا تتحمل أية مسؤولية عن أي أخطاء في البيانات الناتجة عن عمليات النقل أو التحويل او المحادثة.</p>
<p dir="rtl">
</p><p dir="rtl"><strong>مع فائق الاحترام و التقدير</strong></p>
<p dir="rtl"><strong>لجنة المشتريات</strong></p>
<h5><strong>Tender’s Files,</strong></h5>
<h5><strong>5ffb04ba52a49-005-announcement.zip, </strong></h5>
</div>
the page source code.
enter link description here
Using techniques from the following Q/A:
XPath to select all elements between two headings?
Testing text() nodes vs string values in XPath
The following XPath,
//p[ preceding-sibling::h5[starts-with(normalize-space(),'SUBJECT:')]
and following-sibling::h5[normalize-space()='Tender’s Files,']]
will select all p elements between your two targeted headlines, as requested.
Update after OP included actual markup:
Your actual markup includes duplicate
<h5><strong>Tender’s Files,</strong></h5>
headings. The above XPath will select through to the last such heading.
If you want to select through only the first such heading, use this XPath instead:
//p[ preceding-sibling::h5[starts-with(normalize-space(),'SUBJECT:')]
and following-sibling::h5[normalize-space()='Tender’s Files,']
and not(preceding-sibling::h5[normalize-space()='Tender’s Files,'])]
Your xpath should work if you add this:
//p[preceding-sibling::h5//*[contains(text() , 'SUBJECT')] and (following-sibling:: h5//*[contains(text() , 'Tender’s Files,')])[2]]
I have a CSV that looks like this:
25/04/2017,23:35:59,unknown,+123456789,Photo Message
25/04/2017,23:36:09,unknown,+123456789,Сириус конторка
25/04/2017,23:36:15,unknown,+123456789,Главный из офис
26/04/2017,08:15:55,unknown,+123456789,Напишіть будь ласка номер Житло-Капітал, за яким повідомляють:
- суму коштів до повернення/доплати
- комісію за управління інвестиційними коштами
26/04/2017,08:17:44,unknown,+123456789,374-03-08
26/04/2017,08:29:24,unknown,+123456789,Для тех, кто не был на собрании. Вчера мы:
1. Собрали контакты (фио + № квартиры + телефон) тех жильцов, которые пресутствовали на собрании.
2. Подписали заявление по счётчикам тепла.
3. Подписали заявление "щодо недоліків".
4. Коллективное обращение по договорах коммуналки.
5. Инициативная группа рассказала про текущий ход переговоров с жеком по поводу договоров.
Что дальше:
1. Ждём результатов переговоров инициативной группы с жеком. Она должна состояться сегодня.
2. Когда будут готовы согласованные с жеком договора, они будут выложены здесь и на форумах, чтобы каждый мог себе их распечатать, и сравнить с тем, что жек даст на подпись при подписании акта.
2. Кто не подписал заявления/обращения, сможет это сделать до четверга. Где их можно будет подписать - позже узнаем.
26/04/2017,08:29:53,unknown,+123456789,Колективне звернення по договорах комуналки.pdf
26/04/2017,08:29:54,unknown,+123456789,Лист щодо недоліків Забудовнику та Управителю.pdf
26/04/2017,08:29:54,unknown,+123456789,Лічильники тепла - Акцепт.pdf
It has several problems:
line endings are ^M character (see "What does ^M character mean in Vim?"),
final 5th column contains multiline lines,
final 5th column is not properly escaped, e.g. and it's the one that has bare comas sitting around.
What I know for sure that:
the CSV has 5 columns,
line ending is always ^M (e.g. it's Windows-encoded line-ending).
How can I make a proper CSV out of this one?
I think I overreacted about the complexity of this. The following code in Elixir splits the CSV file into correct list of lists:
File.read!("sample.csv")
|> String.split("\r\n")
|> Enum.map(&String.split(&1, ",", parts: 5))
Result:
[
["25/04/2017", "23:36:09", "unknown", "+123456789",
"Сириус конторка"],
["25/04/2017", "23:36:15", "unknown", "+123456789",
"Главный из офис"],
["26/04/2017", "08:15:55", "unknown", "+123456789",
"Напишіть будь ласка номер Житло-Капітал, за яким повідомляють:\n- суму коштів до повернення/доплати\n- комісію за управління інвестиційними коштами"],
["26/04/2017", "08:17:44", "unknown", "+123456789", "374-03-08"],
["26/04/2017", "08:29:24", "unknown", "+123456789",
"Для тех, кто не был на собрании. Вчера мы:\n\n1. Собрали контакты (фио + № квартиры + телефон) тех жильцов, которые пресутствовали на собрании.\n2. Подписали заявление по счётчикам тепла.\n3. Подписали заявление \"щодо недоліків\".\n4. Коллективное обращение по договорах коммуналки.\n5. Инициативная группа рассказала про текущий ход переговоров с жеком по поводу договоров.\n\nЧто дальше: \n1. Ждём результатов переговоров инициативной группы с жеком. Она должна состояться сегодня.\n2. Когда будут готовы согласованные с жеком договора, они будут выложены здесь и на форумах, чтобы каждый мог себе их распечатать, и сравнить с тем, что жек даст на подпись при подписании акта.\n2. Кто не подписал заявления/обращения, сможет это сделать до четверга. Где их можно будет подписать - позже узнаем."],
["26/04/2017", "08:29:53", "unknown", "+123456789",
"Колективне звернення по договорах комуналки.pdf"],
["26/04/2017", "08:29:54", "unknown", "+123456789",
"Лист щодо недоліків Забудовнику та Управителю.pdf"],
["26/04/2017", "08:29:54", "unknown", "+123456789",
"Лічильники тепла - Акцепт.pdf"],
[""]
]
Just in case you want a function that can remove Windows end of line:
" dos2unix ^M
if !exists('*Dos2unixFunction')
fun! Dos2unixFunction() abort
"call Preserve('%s/ $//ge')
call Preserve(":%s/\x0D$//e")
set ff=unix
set bomb
set encoding=utf-8
set fileencoding=utf-8
endfun
endif
com! Dos2Unix :call Dos2unixFunction()
cnoreabbrev dos2unix Dos2unix
cnoreabbrev d2u Dos2Unix
" This function can be called to save your cursor position
if !exists('*Preserve')
function! Preserve(command)
try
let l:win_view = winsaveview()
"silent! keepjumps keeppatterns execute a:command
silent! execute 'keeppatterns keepjumps ' . a:command
finally
call winrestview(l:win_view)
endtry
endfunction
endif
I need to make a reader func in my Swift App. I will receive text (with json request) in HTML like this :
<h5 align="LEFT" class="western" style="font-weight: normal;"> </h5>
<font size="3"><h5 align="LEFT" class="western" style="font-weight: normal;">
Albert Einstein publie en 1905, une nouvelle théorie connue sous le nom de relativité restreinte. </h5>
<h5 align="LEFT" class="western" style="font-weight: normal;"></h5>
<h5 align="LEFT" style="font-weight: normal;"><font color="#339933">►</font>
<font size="3">Postulat 1 :</font>
</h5><h5 align="LEFT" class="western" style="font-weight: normal;">
</h5>
And I want to show it in readable text with all the attribute, I don't want to lose the style, for that I can use HTMLReader.
Do you know a way to make it in Swift ?
These are define in html file, then have to use webview:
objweb.delegate = self
var path = NSBundle.mainBundle().bundlePath
var baseUrl = NSURL.fileURLWithPath("\(path)")
let bundle = NSBundle.mainBundle()
let pathhtml = bundle.pathForResource("Armory", ofType: "html")
let content = NSString.stringWithContentsOfFile(pathhtml) as String
objweb.loadHTMLString(content, baseURL: baseUrl)
self.view.addSubview(objweb)
I've embedded a form built in Marketo on two landing pages on our site. I'm using the same javascript provided by Marketo for both pages (see code below). While the form appears correctly on page 1, the field label and cell appear far to the left on page 2.
Can someone explain why this is happening and how to fix page 2 to look lik page 1?
Page 1 code:
[column lg="3" ] [/column] [column lg="6" md="12" sm="12" xs="12" ]<h4 style="text-align: center;"><span style="color: #000000;"><strong>HEADLINE HERE</strong></span></h4><p style="text-align: center;"><span style="color: #333333;">TEXT HERE</span><br /> <br /> <script src="//app-ab05.marketo.com/js/forms2/js/forms2.js"></script>
<form id="mktoForm_1035"></form>
<script>MktoForms2.loadForm("//app-ab05.marketo.com", "578-AFO-782", 1035);</script>[/column] [column lg="3" ][/column]
Page 2 code:
<p>[column lg="3"] [/column] [column lg="6" md="12" sm="12" xs="12" ]</p>
<h4 style="text-align: center;">TEXT GOES HERE</h4>
<p> </p>
<script src="//app-ab05.marketo.com/js/forms2/js/forms2.js"></script>
<form id="mktoForm_1035"></form>
<script>MktoForms2.loadForm("//app-ab05.marketo.com", "578-AFO-782", 1035);</script>
[/column] [column lg="3"] [/column]</p>
Page 2 looks like it has a few extra paragraph elements that Page 1 does not have. Page 2 is also missing the span element of Page 1. I would recommend removing the paragraph elements and add the span element, and then see if Page 2 looks correct. Try this:
[column lg="3"] [/column] [column lg="6" md="12" sm="12" xs="12" ]
<h4 style="text-align: center;"><span style="color: #000000;"><strong>TEXT GOES HERE</strong></span>
</h4><br /> <br />
<script src="//app-ab05.marketo.com/js/forms2/js/forms2.js"></script>
<form id="mktoForm_1035"></form>
<script>MktoForms2.loadForm("//app-ab05.marketo.com", "578-AFO-782", 1035);</script>
[/column] [column lg="3"] [/column]</p>
Basically when I enter text in an excel cell, I want this (which will be centered):
Weight:10 lbs
Length: 21"
Width: 14"
to become this in another cell:
<p align="center"><font size="2" face="Arial"></font><br></p><p align="center"><font size="2" face="Arial">Weight:10lbs<br></font><span style="font-family: Arial; font-size: small;">Length: 21"<br>Width: 14" </span></p>
I appreciate any help! Thank you!
The other two answers are both very valid. This solution does not use VBA. It is similar to John's except that it uses multiple instances of SUBSTITUTE to create the new text from a template.
Assume Your values are in A2-C2 (This is arbitrary and up to your discretion).
Template in $A$1
<p><br></p>
<p align="center"><font size="2" face="Arial">
{0}<br></font><span style="font-size: small;">{1}<br>{2}"
</span></p>
Result Text
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($A$1, "{0}", A2), "{1}", B2), "{2}", C2)
The advantage over a method that uses concatenation, is that you can radically change the order in which items appear in the template without having to change the function that produces the result.
Even if your template was changed to the one below, the same function using substitute does not have to be changed, which is convenient if you have a low of rows.
<div>{2}<table><tr><td>{0}</td><td>{1}</tr></table></div>
What about:
Cell A1: <p align="center"><font size="2" face="Arial"></font><br></p><p align="center"><font size="2" face="Arial">
Cell B1: Weight:10lbs
Cell C1: <br></font><span style="font-family: Arial; font-size: small;">
Cell D1: Length: 21"
Cell E1: <br>
Cell F1: Width: 14"
Cell G1: </span></p>
And the result you want is
Cell H1: =A1&B1&C1&D1&E1&F1&G1
Rearrange the columns to whatever is convenient, pull out the field names and just use the measurements, etc. ... same idea.
If you already have all three fields in a single cell, then you can split them out into columns easily enough:
If your data are in A1, place =SUBSTITUTE(A1, CHAR(10), "|") to get the data separated by vertical lines in B1.
Paste B1 by value into C1.
Use the Text to Columns tool to separate the fields in C1 into C1 and the adjacent columns, using | as the delimiter.
Your requirement is not clear, this is what I have:
Public Sub Change()
Dim a As String
a = Range("A1:A1")
'MsgBox a
Dim resultCell As Range
Set resultCell = Range("A2:A2")
Dim splitVals As Variant
splitVals = Split(a, Chr(10))
resultCell.Value = "<p align='center'><font size='2' face='Arial'></font><br></p><p align='center'><font size='2' face='Arial'>" & splitVals(0) & "<br></font><span style='font-family: Arial; font-size: small;'>" & splitVals(1) & "<br>" & splitVals(2) & " </span></p>"
End Sub
Put your values in first cell with Alt + enter as new line and you will get your result below that.