extract

How to retrieve comments from within an XML Document in PHP

对着背影说爱祢 提交于 2019-12-17 15:01:12
问题 I want to extract all comments below a specific node within an XML document, using PHP. I have tried both the SimpleXML and DOMDocument methods, but I keep getting blank outputs. Is there a way to retrieve comments from within a document without having to resort to Regex? 回答1: SimpleXML cannot handle comments, but the DOM extension can. Here's how you can extract all the comments. You just have to adapt the XPath expression to target the node you want. $doc = new DOMDocument; $doc->loadXML( '

Extracting data between two tags in HTML file

假装没事ソ 提交于 2019-12-17 14:21:21
问题 I've got a HUUUGE HTML file here saved on my system, which contains data from a product catalogue. The data is structured such that for each product record the name is between two tags (name) and (/name) . Each product has up to 3 attributes: name, productID, and color, but not all products will have all these attributes. How would I go about extracting this data for each product without mixing up the product attributes? The file is also 50 megabyte! Code example .... <name>'hat'</name> blah

PHP String Manipulation: Extract hrefs

六月ゝ 毕业季﹏ 提交于 2019-12-17 07:53:59
问题 I have a string of HTML that I would like to check to see if there are any links inside of it and, if so, extract them and put them in an array. I can do this in jQuery with the simplicity of its selectors but I cannot find the right methods to use in PHP. For example, the string may look like this: <h1>Doctors</h1> <a title="C - G" href="linkl.html">C - G</a> <a title="G - K" href="link2.html">G - K</a> <a title="K - M" href="link3.html">K - M</a> How (in PHP) can i turn it into an array

python pandas extract year from datetime — df['year'] = df['date'].year is not working

你说的曾经没有我的故事 提交于 2019-12-17 04:17:18
问题 Sorry for this question that seems repetitive - I expect the answer will make me feel like a bonehead... but I have not had any luck using answers to the similar questions on SO. I am importing data in through read_csv , but for some reason which I cannot figure out, I am not able to extract the year or month from the dataframe series df['date'] . date Count 6/30/2010 525 7/30/2010 136 8/31/2010 125 9/30/2010 84 10/29/2010 4469 df = pd.read_csv('sample_data.csv',parse_dates=True) df['date'] =

python pandas extract year from datetime — df['year'] = df['date'].year is not working

南笙酒味 提交于 2019-12-17 04:17:09
问题 Sorry for this question that seems repetitive - I expect the answer will make me feel like a bonehead... but I have not had any luck using answers to the similar questions on SO. I am importing data in through read_csv , but for some reason which I cannot figure out, I am not able to extract the year or month from the dataframe series df['date'] . date Count 6/30/2010 525 7/30/2010 136 8/31/2010 125 9/30/2010 84 10/29/2010 4469 df = pd.read_csv('sample_data.csv',parse_dates=True) df['date'] =

Extracting data belonging to a day from a given range of dates on a dataset

回眸只為那壹抹淺笑 提交于 2019-12-14 03:52:31
问题 I have a data set with a date range from January 12th to August 3rd of 2018 with some values: The dimensionality of my_df DataFrame is: my_df.shape (9752, 2) Each row contains half hour frequency The first row begins at 2018-01-12 my_df.iloc[0] Date: 2018-01-12 00:17:28 Value 1 Name: 0, dtype: object And the last row ending at 2018-08-03 my_df.tail(1) Date: Value 9751 2018-08-03 23:44:59 1 My goal is to select the data rows corresponding to each day and export it to a CSV file. To get only

How can I extract XML of a website and save in a file using Perl's LWP?

北城以北 提交于 2019-12-14 03:49:38
问题 How can I extract information from a website (http://tv.yahoo.com/listings) and then create an XML file out of it? I want to save it so to parse later and display information using JavaScript? I am quite new to Perl and I have no idea about how to do it. 回答1: Of course. The easiest way would be the Web::Scraper module. What it does is it lets you define scraper objects that consist of hash key names, XPath expressions that locate elements of interest, and code to extract bits of data from

Simple Java regex to extract IP address and port from enclosing string

橙三吉。 提交于 2019-12-14 02:36:34
问题 Consider a pair of IPv4 or IPv6 address and port, separated by either / or : , e.g. 10.10.10.10:1234 The port is optional, so strings like 10.10.10.10/ 10.10.10.10: 10.10.10.10 are also valid. The address/port pair may be followed by space or comma characters and it is part of a much longer enclosing string. What would be a very simple regex to extract the 2 values in separate fields from the enclosing string (without using String manipulation functions)? For example, an expression like (?

How to extract audio/video clips using the libvlc API or FFmpeg API?

喜你入骨 提交于 2019-12-14 01:32:52
问题 I am supporting a C++/Qt application that uses libvlc to playback audio/video streams. My task is to enhance the application to allow the users to extract video clips by setting start / end times and capturing the video in between to a file. I've implemented the start/end markers, and can seek the audio/video to the correct times for playback. My problem now is to somehow capture this stream to a file in a variety of formats / compressions. I've been searching through the Doxygen links in

extract specific string in NSString

五迷三道 提交于 2019-12-14 00:42:01
问题 i think it is a simple question but i dont know how to solve it. i have a NSString that containes html content. i want to extract some tags. NSString *string=@"test some text <img src='http://www.xyz.com/a.jpg' > blah blah <a href='asdfg'>aaaa</a> bbbb cccc"; i want to take img & "a" tag into new string. then i will display it in UIWebView. how can i parse it? 回答1: The best way is to write a partial tag parser. This is not very difficult. Another option is to simply find the position of src='