htmliosiphonexpathhpple

Hpple Element returning with null content


I am trying to parse HTML using an Xpath query string (in Objective-C for iOS). I'm grabbing the element I want, but with everything except the contents.

Example html:

<textarea type="text" name="name" style="width: 100px; height:100px;"/>Contents</textarea>

My attempt to grab the element:

TFHpple *parser = [TFHpple hppleWithHTMLData:response];
NSString *XpathQueryString = @"//textarea[@name='name']";
NSArray *nodes = [parser searchWithXPathQuery:XpathQueryString];

NSLog of the element in the nodes array:

nodeAttributeArray =     (
            {
        attributeName = type;
        nodeContent = text;
    },
            {
        attributeName = name;
        nodeContent = name;
    },
            {
        attributeName = style;
        nodeContent = "width: 100px; height:100px;";
    }
);
nodeName = textarea;
raw = "<textarea type=\"text\" name=\"name\" style=\"width: 100px; height:100px;\"></textarea>";
}

No contents. Any ideas as to what is going wrong?

Thanks in advance!


Solution

  • Looks like this is a case of bad html. The tag self closes but also has a separate closing tag.

    Should like like this:

    <textarea type="text" name="name" style="width: 100px; height:100px;">Contents</textarea>