Closed poojagaonkar closed 7 years ago
@poojagaonkar Hey, I see that you've closed the issue already. Do you still need help with your problem? Will be glad to help 😉
Hey,
Thanks for replying. I couldn't solve the issue, but could continue without using the feature for the time being.
It would be nice if you could still help me solve it if I need to implement it in future.
Thanks again :)
Pooja
On Feb 11, 2017 5:20 PM, "Iskandar Abudiab" notifications@github.com wrote:
@poojagaonkar https://github.com/poojagaonkar Hey, I see that you've closed the issue already. Do you still need help with your problem? Will be glad to help 😉
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/iabudiab/HTMLKit/issues/3#issuecomment-279139090, or mute the thread https://github.com/notifications/unsubscribe-auth/AHfiLJDBJgl_tYuX3m61f8jRtEdV0071ks5rbaBpgaJpZM4L-DeY .
Hey, no problem. First things first, I'm not really sure what you are trying to accomplish and why you are using the fragment parsing, so here is my interpretation:
// First you parse the htmlString into a document
HTMLDocument *doc = [HTMLDocument documentWithString:htmlString];
// Then you qeury the document for all input elements that are hidden
NSArray *hiddenInputs = [doc querySelectorAll:@"input[type=hidden]"];
// Now you iterate the elements array
for (HTMLElement *element in hiddenInputs) {
NSLog(@"%@: %@", element.attributes[@"name"], element.attributes[@"value"]);
}
You couldn't access the attributes
in your case because you were iterating an array of HTMLNode
s. A HTMLNode can be any type of DOM node, e.g. a text node or comment node, but only HTMLElement
s have attributes.
So in your case you have to check the node's type and cast accordingly. something like this:
for (HTMLNode *node in nodes) {
if (node.nodeType != HTMLNodeElement) {
continue;
}
HTMLElement *element = (HTMLElement *)node;
// You logic here
}
Let me know if this answers your questions.
Hello,
First of all, a very nice library you have created here. I am using it for a feature in my app where I need to load a HTML string , select node with particular tags and fetch the attributes of name and value from those tags. I have reached this far :
It would be great if you could help me out and guide me in the right direction as I am quite new to iOS. Thank you.