Posts

python - How to get path of an element in lxml? -

I'm searching in an HTML document using XPath from LXML in Python. How do I get the path of a certain element? Here is an example from Ruby Notchri: Page Xpath ('// text ()'). Every do Textnode | Path = textnode.path for example puts the end of the path to ' / html / body / div / div [1] / div [1] / p / text () [1] ] 'and this is the string that I want to get in Python. Use Elementary Object. Lxml Import Entry Root = etree.fromstring (' '& lt; baz & gt; data & lt; / baz & gt; & lt; / bar & gt; & lt; / foo & gt; ') Tree = etree.ElementTree (root) for root.iter (): print tree.getpath (e) print / foo / Foo / bar [1] / foo / bar [2] / af / bar [2] / falcon [1] / af / bar [2] / falcon [2]

C++ sorting and keeping track of indexes -

Using C ++, and hopefully standard library, I want to sort the order of the samples in ascending order, but I also want to remember the original indexes of new samples. For example, I have a set, or matrix of vector or samples A: [5, 2, 1, 4, 3] . I want to sort these by: B: [1,2,3,4,5] , but I have to remember the original index of values, so I can get another set which is: C: [2, 1, 4, 3, 0] - that matches the indicator of each element in 'A', in the original 'A' For example, you can do this in Matlab: [a, b] = sort ([5, 8, 7]) a = 5 7 8 b = 1 3 2 Can anyone see a good way of doing this? Using C ++ 11 Lambda template & lt ; Typename T & gt; The vector & lt; Size_t> Sort_indexes (const vector & lt; T & gt; & amp; v) {// Start original index locations vector & lt; Size_t> IDX (v.size ()); Item (idx.begin (), idx.end (), 0); // Sort sorted values ​​v variant (idx.begin (), idx.end (), [& amp; v] (size_t i1, size_t i...

html - What is practical purpose for bidirectional override "bdo"? -

Before coming here, I tried myself by googling after reading these two links I still do not clearly understand what the practical purpose is? Thanks to those who put some light on it. Beautiful striaghtforward If you are writing a web page using a default language, like English, Left to right is provided, and you want to include an island of text in another language, such as a quote in Hebrew, which is right-to-left you can use this tag to override the base In which the text is written on the page, if the bi-directional algorithm In going wrong you need to make sure that there are any font you use that also supports the appropriate character set.

css - block-level anchor not taking up space around text [IE7] -

I have an anchor tag with some simple CSS: div {background- Color: gray; / * For debugging * /} div {display: block; Padding: 6px 4px 6px 7px; Background color: red; In Firefox, the anchor (red) is also clickable beyond the text because it is because it display: block occurs with something / / for the dblogging cushion In IE7, when I slip into red area which is not text, then the anchor is no longer a link. element to add zoom: 1 , Which is not only 60% of all IE bugs (according to a survey created to make this point), but also attempts to plague block-level anchors. / Html>

redirect - In Asp.Net, check for existence of aspx page before redirecting to it? -

How can I check the existence of an aspx page before I try to redirect it, So that's my C # code in that case? response. Radical ("~ / SomePage.aspx") But I have to make sure that the page actually exists before I call it. It works with the string after all, so maybe I have some type or something else, or maybe I have not created that page yet. Do one on the page. if (file example (server.mappath ("~ / SomePage.aspx"))) Response.Redirect ("~ / SomePage.aspx"); You have a system Io will use the namespace.

Java Properties object to String -

मेरे पास Java Properties ऑब्जेक्ट है जो मैं इन-मेमोरी से String , जो पहले वास्तविक .properties फ़ाइल से इस तरह से स्मृति में लोड किया गया था: this.propertyFilesCache.put (file, FileUtils.fileToString (propfile) ); उपयोग fileToString वास्तव में फ़ाइल से पाठ में पढ़ता है और बाकी के कोड को इसे hashmap call propertyFilesCache । बाद में, मैं हाशम से स्ट्रिंग के रूप में फाइल टेक्स्ट पढ़ता हूं और इसे जावा में properties ऑब्जेक्ट में पुनः लोड करता हूं: स्ट्रिंग प्रोफाइलसट्र = यह.प्रॉपर्टीफ़ाइलों Cache.get (fileName); गुण tempProps = नए गुण (); {TempProps.load (नई बाइटअरेइनपुटस्ट्रीम (प्रोफिल एसटेट बटेट्स ()) का प्रयास करें; } पकड़ (अपवाद ई) {लॉग। Debug (e.getMessage ()); } TempProps.setProperty (सहारा, propVal); इस बिंदु पर, मैंने अपनी प्रॉपर्टी को अपनी इन-मेमरी प्रॉपर्टी फाइल में बदल दिया है और मैं टेक्स्ट को Properties ऑब्जेक्ट से प्राप्त करना चाहता हूं जैसे कि मैं था एक फ़ाइल ऑब्जेक्ट पढ़ना जैसे मैंने ऊपर किया क्या ऐसा करने का एक आसान तरीका है या क्या मैं...

c++ - ASSERT fails on CDC SelectObject() call - What can I try? -

I am working on a multi-threaded Win32 MFC application. We are providing a map and displaying it in a user's pane with custom-render objects at the top of the user interface. This user interface is going on the thread (~ 800 ms) is slow to render. I am trying to move on my own thread to the rendering so that the menu can still be sharp, while others may still be rendering in the background. The draw thread will continuously render using the CDC. The UI thread will call a radra function, which locks the Mute X, and takes the last snapshot of cbtmap and pulls it using the UI's CDC each location Where the thread's cd C is used, it is locked by Mute X. What I see is that thread through a new CBitmap CreatCompatibleBitmap , and then in the CDC of draw threads Attempting to select the new CBITmap object. this - & gt; M_canvas.CreateCompatibleDC (& compatibleDC); This- & gt; M_bitmap = new CBitmap (); This- & gt; M_bitmap-> CreateCompatib...