monkeytooth Posted February 23, 2011 Share Posted February 23, 2011 The raw output is this.. full example: http://instant.simplyhired.com/a/jobs/xml-v1/l-06238/q-engineer/ws-100/si-0/fdb-21/sb-rd/mi-10 I can generally get the value of this stuff.. like if I wanted the "jt" line I can get ENGINEER, and the rest of the data.. what i am having trouble with is getting the attribute (i think thats the right term for this with XML). For example the "src" line it as an attribute "url=" I am trying to figure out how to get that value.. Below is a sample of the raw.. and below that is the code I am working with to load up the XML. I know theres simple_xml but in my case thats not an option so I am working on slightly custom work (as little as it is). <r> <jt>ENGINEER</jt> <cn url="">Soldream</cn> <src url="http://instant.simplyhired.com/a/job-details/view/jobkey-5109.J3H3036RVZPZ4RFRRKR/jp-0/hits-70?aff_id=2512">CareerBuilder</src> <loc cty="Tolland" st="CT" postal="06084" county="" region="" country="US">Tolland, CT</loc> <ls>2011-02-20T13:28:39Z</ls> <dp>2011-02-18T08:00:00Z</dp> <e>Engineer/CNC Machinist Tolland CT2429177 Aerospace MFG Co. seeks MFG/Design Engineer & CNC Machinist with 5+ years of experience in aerospace manufacturing. Duties for engineers include developing new processes, drafting, and CNC programming. CNC Machinist should have knowledge of FANUC control. Send resume to...</e> <af></af> <pl url=""/> </r> $feedURL = 'http://instant.simplyhired.com/a/jobs/xml-v1/l-06238/q-engineer/ws-100/si-0/fdb-21/sb-rd/mi-10'; $doc = new DOMDocument(); $doc->load($feedURL); $arrFeeds = array(); foreach ($doc->getElementsByTagName('r') as $node) { $itemRSS = array ( 'title' => $node->getElementsByTagName('jt')->item(0)->nodeValue, 'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue, 'link' => $node->getAttributeNode('src'), 'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue, 'creator' => $node->getElementsByTagName('creator')->item(0)->nodeValue, 'permaz' => $node->getElementsByTagName('guid')->item(0)->nodeValue ); array_push($arrFeeds, $itemRSS); //print_r($arrFeeds); } array_unique($arrFeeds); ?> Link to comment https://forums.phpfreaks.com/topic/228619-php-xml-not-a-standard-format/ Share on other sites More sharing options...
btherl Posted February 23, 2011 Share Posted February 23, 2011 DOMDocument::GetElementsByTagName() returns a DOMNodeList, and each item is a DOMNode. A DOMNode has a hasAttributes() method, and an attributes property of type DOMNamedNodeMap. I would expect the attributes to be in there, and accessible using DOMNamedNodeMap::getNamedItem() Link to comment https://forums.phpfreaks.com/topic/228619-php-xml-not-a-standard-format/#findComment-1178837 Share on other sites More sharing options...
monkeytooth Posted February 23, 2011 Author Share Posted February 23, 2011 Yea, I finally got it I should have come bakc here and tagged it as solved. But thank you I realized I was forgetting a piece of the puzzle, and I was sleepy so it didnt make sense then Link to comment https://forums.phpfreaks.com/topic/228619-php-xml-not-a-standard-format/#findComment-1178849 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.