Choosing the right IOS XML parser [closed] - ios

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
There are a million different XML parsers for the iPhone. I have a medium sized XML file that contains alot of duplicate tags (at different points in the hierarchy). I was thinking about TBXML but I was concerned about its lack of XPath support. For instance lets say my XML file looked like this.
<blog>
<author> foo1 </author>
<comments>
<comment>
<text>
<![CDATA[ HTML code that must be extracted ]]>
</text>
<author>foo2</author>
</comment>
<comment>
<text>
<![CDATA[ Here is another post ]]>
</text>
<author>foo1</author>
</comment>
</comments>
</blog>
Basically my requirements are that I need to be able to extract that cdata. And know whether it is the blog author a comment author.

Best comparison I've seen on the subject:
http://www.raywenderlich.com/553/how-to-chose-the-best-xml-parser-for-your-iphone-project
The difference between the slowest and fastest parsers in his case was a factor of 2. Depending on your feature requirements, there are definitely parsers that can cut your parsing time in half.

Check out RaptureXML. It's not official XPath behavior, but it's pretty close. Your query would be:
[rxml iterate:#"comments.comment" with: ^(RXMLElement *e) {
if ([[e child:#"author"].text isEqualToString:#"foo1"]) {
NSLog(#"Blog Text is %#.", e.text);
} else {
NSLog(#"Comment Text is %#.", e.text);
}
}];
UPDATE: RaptureXML now supports XPath!

You should look at these libraries, in order :)
Ono, powered by libxml2
XMLDictionary
RaptureXML
Ono has the the cool AFOnoResponseSerializer which can be integrated with AFNetworking

I made this new simple and lightweight XML parser for iOS in Swift - AEXML
You can use it to read XML data like this:
let someValue = xmlDocument["element"]["child"]["anotherChild"].value
or you can use it to build XML string like this:
let document = AEXMLDocument()
let element = document.addChild("element")
element.addChild("child")
document.xmlString // returns XML string of the entire document structure
I hope it will be useful for someone.

As you have requirement for medium sized XML
TinyXML could be an good choice for medium sized documents if you already have experience with the API and are comfortable with C as it ports quite easily over to the iPhone.
For More information you can go through this link

Related

Can I find all music files on computer with electron? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 1 year ago.
Improve this question
I'm thinking about making music player for linux but i'm not sure if it's possible to find all music files and what should i use for that.
You can achieve this using node's walk package.
You'll want the user to select a folder where music is stored because it would take a lot of time to search through every directory on user's machine and find .mp3 files.
It is pretty well documented. It takes the path to the selected folder and loops through all files. Pretty straightforward.
something like this might work
const walk = require('walk');
const files = []
const walker = walk.walk("music/", { followLinks: false });
walker.on('file', function(root, fileStats, next) {
// Add file to the list
files.push(root + '/' + fileStats.name);
next();
});
walker.on('end', function() {
console.log(files);
});

How to render write complex mathematics equations in nativescript-vue? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
There is this plugin (https://github.com/zzish/react-latex#readme) that renders LaTex in React. Is there a way to use a similar plugin in NativeScript-Vue?
Firstly, that is a React component and not a ReactNative component. That component is a wrapper to Katex, which renders LaTex to HTML.
A way to use it NativeScript-Vue is to render LaTex to html render it in a <WebView>, like so:
<template>
...
<WebView :src="exprHtml" height="100"/>
...
</template>
<script>
...
mounted() {
this.exprHtml = katex.renderToString("c = \\pm\\sqrt{a^2 + b^2}", {
throwOnError: false
});
}
</script>
You can find a working playground example here.
Note that the <WebView> component is like a mini browser added inside your app. Don't add too many of them in a single screen.

RSS Feed fetching incomplete description - Swift 3

I am using Swift Feed Parser for RSS feeds. Everything works fine except that I am unable to fetch the complete description. The description is under the <content:encoded> tag in my RSS feed. So how do I fetch that?
I am using this code given in their demo to fetch <description> tag:
if let subtitleLabel = cell.viewWithTag(3) as? UILabel {
subtitleLabel.text = item.feedContentSnippet ?? item.feedContent?.stringByDecodingHTMLEntities() ?? ""
}
Please help. I am using Xcode 8 and Swift 3.
So, let's try to suggest some hints on how to approach this:
First, the [...] was coming from the RSS feed <description> itself and not from the parser, so this one is solved
In order to extract instead the <content:encoded> tag from the feed you should I guess modify a little bit the feed parsing library, after quickly looking at it's source code, it doesn't seem to look for <content:encoded> anywhere
Your best bet would be to modify the FeedParser class here, especially the function parseEndOfAtomElement or similar (they have different parsers for each RSS feed type they support)
Please tell us if it worked.

How to iterate line by line through a .docx file using apache POI [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
My object is to read a .docx file and to display the text of that on the view(Webpage).
I am using apache POI to read a .docx file in Grails Application
Please suggest me a way to display the output on view without loosing Blankspaces and LineBreaks.
My .docx document content
This is a .docx document ...
this is second line
this is third line
Result on Groovy console after reading when i am printing :
This is a .docx document ...
this is second line
this is third line
But when i pass the output to view It becomes
This is a .docx document ... this is second line this is third line
.
My code is :
import org.apache.poi.xwpf.usermodel.XWPFDocument
import org.apache.poi.xwpf.extractor.XWPFWordExtractor
...
String str = "E:\\Query.docx"
File docFile = null;
docFile = new File(str);
FileInputStream fis=new FileInputStream(docFile.getAbsolutePath());
XWPFDocument doc = new XWPFDocument(fis)
XWPFWordExtractor docExtractor = new XWPFWordExtractor(doc)
println docExtractor.getText()
...
if one can suggest me the way to iterate through each line of the document then i can easily get my result.
Please help me i have got stucked.
HTML ignores line breaks. So, while a string like "Hello there\nLine 2\n" renders fine in the console as
Hello There
Line 2
As HTML it'll all show on the same line. You'll need to replace the newline characters with some suitable HTML, eg <br /> or wrapping things in paragraph/div tags.

Need an API to find a full company name given a ticker symbol [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I need a way from within client-side Javascript to find a full company name given a ticker symbol. I am aware of Yahoo Finance's interface at:
http://finance.yahoo.com/d/quotes.csv?s=TKR&f=n
and am able to access that via YQL (since this is cross-domain). However, that doesn't return the full company name, yet Yahoo Finance has such because it appears in their charts for the company and on their pages about the company.
I don't need for the solution to be via Yahoo Finance... just mention it here as I already know about it (and am accessing it for other data).
One of the community-provided YQL tables looks like it will work for you: yahoo.finance.stocks.
Example YQL query:
select CompanyName from yahoo.finance.stocks where symbol="TKR"
Update 2012-02-10: As firebush points out in the comments, this YQL community table (yahoo.finance.stocks) doesn't seem to be working correctly any more, probably because the HTML page structures on finance.yahoo.com have changed. This is a good example of the downside of any YQL tables that rely on HTML scraping rather than a true API. (Which for Yahoo Finance doesn't exist, unfortunately.)
It looks like the community table for Google Finance is still working, so this may be an alternative to try: select * from google.igoogle.stock where stock='TRK';
I have screen scrapped this information in the past either using Yahoo Finance or MSN Money. For instance you can get this information for ExxonMobil by going to (link). As far as an API you might need to build one yourself. For an API checkout Xignite.
You can use the "Company Search" operation in the Company Fundamentals API here: http://www.mergent.com/servius/
You can use Yahoo's look up service using Jonathan Christian's .NET api that is available on NuGet under "Yahoo Stock Quotes".
https://github.com/jchristian/yahoo_stock_quotes
//Create the quote service
var quote_service = new QuoteService();
//Get a quote
var quotes = quote_service.Quote("MSFT", "GOOG").Return(QuoteReturnParameter.Symbol,
QuoteReturnParameter.Name,
QuoteReturnParameter.LatestTradePrice,
QuoteReturnParameter.LatestTradeTime);
//Get info from the quotes
foreach (var quote in quotes)
{
Console.WriteLine("{0} - {1} - {2} - {3}", quote.Symbol, quote.Name, quote.LatestTradePrice, quote.LatestTradeTime);
}
EDIT: After posting this I tried this exact code and it was not working for me so instead I used the Yahoo Finance Managed Api however it's not available via NuGet. A good example of use here
QuotesDownload dl = new QuotesDownload();
DownloadClient<QuotesResult> baseDl = dl;
QuotesDownloadSettings settings = dl.Settings;
settings.IDs = new string[] { "MSFT", "GOOG", "YHOO" };
settings.Properties = new QuoteProperty[] { QuoteProperty.Symbol,
QuoteProperty.Name,
QuoteProperty.LastTradePriceOnly
};
SettingsBase baseSettings = baseDl.Settings;
Response<QuotesResult> resp = baseDl.Download();
Also if you just want to download the stuff stocktwits api has a download link for the symbology and industries under "Resources" http://stocktwits.com/developers/docs
It also possible to use Quandl.com resources. Their WIKI database contains 3339 major stocks and can be fetched via secwiki_tickers.csv file. For a plain file portfolio.lst storing the list of your tickers (stocks in US markets), e.g.:
AAPL
IBM
JNJ
MSFT
TXN
you can scan the .csv file for the name, e.g:
import pandas as pd
df = pd.read_csv('secwiki_tickers.csv')
dp = pd.read_csv('portfolio.lst',names=['pTicker'])
pTickers = dp.pTicker.values # converts into a list
tmpTickers = []
for i in range(len(pTickers)):
test = df[df.Ticker==pTickers[i]]
if not (test.empty):
print("%-10s%s" % (pTickers[i], list(test.Name.values)[0]))
what returns:
AAPL Apple Inc.
IBM International Business Machines Corporation
JNJ Johnson & Johnson
MSFT Microsoft Corporation
TXN Texas Instruments Inc.
It is possible to combine more stocks from other Quandl's resources. See the documentation online.

Resources