Hello,
Can anyone tell me how to parse a local xml file stored in the system using SAX ,with an example code.please also tell me where can i find information on that
Hi,
I want to parse google and yandex search results for my little website analyzer utility.
so i should send hundreds requests per minute. What is good practice for this issue?
Is google search api a good way?
"8,5,,1,4,7,,,,7,,1,9,3,6,,,8,6,3,9,,2,5,4,,,,,3,2,,,7,4,1,1,,4,,6,9,,5,,,,5,,,1,,6,3,,,6,5,,,,7,4,,1,7,6,,,,8,,5,,,7,1,,3,9,"
I'm doing a programming challenge where i need to parse this sequence into my sudoku script.
Need to get the above sequence into 8,5,0,1,4,7,0,0,0,7,0,1,9,3,6,0,0,8.........
I tried re but without success, help is appreciated, thanks.
How can I do the equivalent of the Ruby snippet below using Java?
require 'net/http'
res = Net::HTTP.get_response(URI.parse("http://somewhere.com/isalive")).body
How can I cache an XSD schema (residing on disk) to be reused when parsing XMLs in Xerces (C++)?
I would like to load the XSD schema when starting the process, then, whenever I need to parse an XML, to validate it first using this loaded schema.
i am using XML as my backend for the application...
LXML is used to parse the xml.
How can i encrypt this xml file to make sure that the data is protected......
thanks in advance.
I want to test a service (Bar) that invokes another service (Foo) and returns a promise. The test is currently failing with this error:
Error: Unexpected request: GET foo.json
No more request expected
Here are the service definitions:
// Foo service returns new objects having get function returning a promise
angular.module('foo', []).
factory('Foo', ['$http', function ($http) {
function FooFactory(config) {
var Foo = function (config) {
angular.extend(this, config);
};
Foo.prototype = {
get: function (url, params, successFn, errorFn) {
successFn = successFn || function (response) {};
errorFn = errorFn || function (response) {};
return $http.get(url, {}).then(successFn, errorFn);
}
};
return new Foo(config);
};
return FooFactory;
}]);
// Bar service uses Foo service
angular.module('bar', ['foo']).
factory('Bar', ['Foo', function (Foo) {
var foo = Foo();
return {
getCurrentTime: function () {
return foo.get('foo.json', {}, function (response) {
return Date.parse(response.data.now);
});
}
};
}]);
Here is my current test:
'use strict';
describe('bar tests', function () {
var currentTime, currentTimeInMs, $q, $rootScope, mockFoo, mockFooFactory, Foo, Bar, now;
currentTime = "March 26, 2014 13:10 UTC";
currentTimeInMs = Date.parse(currentTime);
beforeEach(function () {
// stub out enough of Foo to satisfy Bar service:
// create mock object with function get: function(url, params, successFn, errorFn)
// that promises to return a response with this property
// { data: { now: "March 26, 2014 13:10 UTC" }})
mockFoo = {
get: function (url, params, successFn, errorFn) {
successFn = successFn || function (response) {};
errorFn = errorFn || function (response) {};
// setup deferred promise
var deferred = $q.defer();
deferred.resolve({data: { now: currentTime }});
return (deferred.promise).then(successFn, errorFn);
}
};
// create mock Foo service
mockFooFactory = function(config) {
return mockFoo;
};
module(function ($provide) {
$provide.value('Foo', mockFooFactory);
});
module('bar');
inject(function (_$q_, _$rootScope_, _Foo_, _Bar_) {
$q = _$q_;
$rootScope = _$rootScope_;
Foo = _Foo_;
Bar = _Bar_;
});
});
it('getCurrentTime should return currentTimeInMs', function () {
Bar.getCurrentTime().then(function (serverCurrentTime) {
now = serverCurrentTime;
});
$rootScope.$apply(); // resolve Bar promise
expect(now).toEqual(currentTimeInMs);
});
});
The error is being thrown at $rootScope.$apply(). I also tried using $rootScope.$digest(), but it gives the same error.
Thanks in advance for any insight you can give me.
I need to read a file and send the text from it to a string so I can parse it. However, the program won't know exactly how long the file is so what would I do if I wanted to use fgets, or is there a better alternative?
Note:
char * fgets ( char * str, int num, FILE * stream );
I need to determind when a file has been uploaded via an ftp account so i can parse the data and insert into a db.
I could do this 2 different ways, either set up a schedule or watch the directory for any change. Either option would be fine.
I'm new to the apache /php space so any keywords that i can search upon would be handy.
Thanks.
Hi All,
In my project i using LibXml to parse data, when i select a row in first controller i will take to next conttroller where i will get data using libxml if i click on the back button while loading the page i am getting exception. if i click afetr loading is completed it is working fine ca any one help me.
the exception is showing here
(void)connection:(NSURLConnection *)connection
didReceiveData:(NSData *)data {
// Process the downloaded chunk of data.
xmlParseChunk(_xmlParserContext, (const char *)[data bytes], [data length], 0);
}
Thank You
Hi,
is there any possibility to send from formtastic form value of :string field like
- semantic_form_for :project do |form|
- form.inputs do
= form.input :task_ids, :as => :string
as Array? Currently value of this field is sending as String and i'd like to no parse this string in controller.
Also, could you give me idea - if task with submitted id is not found - what is best way to catch this situation - validation in controller or what?
Hi, what I want to do is have a PHP script run a program and have it retrieve data somehow from it. For instance the program would parse data from a file and return the data for the PHP script to display.
So far I know to call exec("Program.exe"); but would I have to make it create a file with the data then have the PHP script call fopen and get it that way? Is there a better way to do it? Thanks
Hey guys, I have the following HTML structure that I am trying to pull information from:
// Product 1
<div class="productName">
<span id="product-name-1">Product Name 1</span>
</div>
<div class="productDetail">
<span class="warehouse">Warehouse 1, ACT</span>
<span class="quantityInStock">25</span>
</div>
// Product 2
<div class="productName">
<span id="product-name-2">Product Name 2</span>
</div>
<div class="productDetail">
<span class="warehouse">Warehouse 2, ACT</span>
<span class="quantityInStock">25</span>
</div>
…
// Product X
<div class="productName">
<span id="product-name-X">Product Name X</span>
</div>
<div class="productDetail">
<span class="warehouse">Warehouse X, ACT</span>
<span class="quantityInStock">25</span>
</div>
I don't have control of the source html and as you'll see productName and it's accompanying productDetail are not contained within a common element.
Now, I am using the following php code to try and parse the page.
$html = new DOMDocument();
$html->loadHtmlFile('product_test.html');
$xPath = new DOMXPath($html);
$domQuery = '//div[@class="productName"]|//div[@class="productDetail"]';
$entries = $xPath->query($domQuery);
foreach ($entries as $entry) {
echo "Detail: " . $entry->nodeValue) . "<br />\n";
}
Which prints the following:
Detail: Product Name 1
Detail: Warehouse 1, ACT
Detail: 25
Detail: Product Name 2
Detail: Warehouse 2, ACT
Detail: 25
Detail: Product Name X
Detail: Warehouse X, ACT
Detail: 25
Now, this is close to what I want. But I need to do some processing on each Product, Warehouse and Quantity stock and can't figure out how to parse it out into separate product groups. The final output I am after is something like:
Product 1:
Name: Product Name 1
Warehouse: Warehouse 1, ACT
Stock: 25
Product 2:
Name: Product Name 2
Warehouse: Warehouse 2, ACT
Stock: 25
I can't just figure it out, and I can't wrap my head around this DOM stuff as the elements don't quite work the same as a standard array.
If anyone can assist, or point me in the right direction I will be ever appreciative.
the model is :
class someModel(db.Model):
name = db.StringProperty()
def name_is_sss(self):
return self.name=='sss'
the view is :
a=someModel()
a.name='sss'
path = os.path.join(os.path.dirname(__file__), os.path.join('templates', 'blog/a.html'))
self.response.out.write(template.render(path, {'a':a}))
and the html is :
{{ a.name_is_sss }}
the page shows :
True
so i want to make it more useful, and like this:
the model:
class someModel(db.Model):
name = db.StringProperty()
def name_is_x(self,x):
return self.name==x
the html is :
{% a.name_is_x 'www'%}
or
{{ a.name_is_x 'www'}}
but the error is :
TemplateSyntaxError: Invalid block tag: 'a.name_is_x'
or
TemplateSyntaxError: Could not parse the remainder: 'www'
so how to make my method running
thanks
I have this xml model.
link text
So I have to add some node (see the text commented) to this file.
How I can do it?
I have writed this partial code but it doesn't work:
xmldoc=minidom.parse(directory)
child = xmldoc.createElement("map")
for node in xmldoc.getElementsByTagName("Environment"):
node.appendChild(child)
Thanks in advance.
greeting all
i want to use a mail server
where the users send emails to it
and then i parse this emails then do some action
please suggest me what mail server to be used
and where to start
some links,tutorials,guide is very appreciated .
I am trying to display a WordPress post on the homepage of a site. It is reporting the following error:
Parse error: syntax error, unexpected '=' in /home/####/####/####/####/wp-content/themes/oceanswaves/home.php on line 105
<?php query_posts(‘p=143'); if(have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endif; ?>
Thank you
As per the title, I'm trying to parse an XML file containing an xs:duration data type. I'd like to convert that into a Python timedelta object, which I can then use in further calculations.
Is there any built-in way of doing this? If not, what is the best way to achieve this?
I'd like my Python script to read some data out of a postgresql dump file. The Python will be running on a system without postgresql, and needs to process the data in a dump file.
It looks fairly straightforward to parse the CREATE TABLE calls to find the column names, then the INSERT INTO rows to build the contents. But I'm sure there would be quite a few gotchas in doing this reliably. Does anyone know of a module which will do this?
I am trying to create a link, which will, allow my paginated search to go onto the next page of results including the search term in the url
I get the following error with the link I have created
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/dd615/public_html/searchPage.php on line 47
here is the link
echo "<a href='{$_SERVER['PHP_SELF']}?search=$_GET['search']?pagenumber=1'> FIRST </a>";
any help would be greatly appreciated
This is my test-string:
<img rel="{objectid:498,newobject:1,fileid:338}" width="80" height="60" align="left" src="../../../../files/jpg1/Desert1.jpg" alt="" />
I want to get each of the JSON formed Elements inbetween the rel attribute.
It's working for the first element (objectid).
Here is my ReqEx, which works fine:
(?<=(rel="\{objectid:))\d+(?=[,|\}])
But i want to do somthing like this, which doesn't work:
(?<=(rel="\{.*objectid:))\d+(?=[,|\}])
So i can parse every element of the search string.
I'm using Java-ReqEx
Hello,
I have an ANTLR grammar that can parse and evaluate simple expressions like 1+2*4, etc.
What I would like to do is to evaluate expressions like 2+$a-$b/4 where the $ variables are dynamic variables, that come from an external source and are continuously updated.
Is there any design pattern on how to do this using ANTLR, best practices, etc?
Shall I "substring" the $a with the updated value ($a - 4.34)
A nicer way to do this?
Thx
Hardware accelaration and embedded programming has mostly been used so far to parse datafeed and/or to route orders to exchange. Have there been attempts to write simpler HFT strategies such as equity market-making in hardware? Have they been successful? Which companies are doing this and what kind of programming model is used?
has anybody found a library that works well with large spreadsheets?
I've tried apache's POI but it fails miserably working with large files - both reading and writing. It uses massive amounts of memory leaving you needing a supercomputer to parse or create a 20+mb spreadsheet.
Surely there is a more memory efficient way and someone has written it?!