JonnyThunder Posted July 13, 2008 Share Posted July 13, 2008 Hello all! First time poster on here, hope you can help me out. Here is my code. When run, it displays nothing! Why doesn't it show the ID attribute as I would expect.... $str = '<?xml version="1.0" encoding="iso-8859-1"?> <FORM> <FIELD ID="fld_inputbox"> <TYPE>inputbox</TYPE> <MAXCHARS>20</MAXCHARS> <DISPLAYCHARS>10</DISPLAYCHARS> <DEFAULTVALUE>Hello World</DEFAULTVALUE> </FIELD> <FIELD ID="fld_dropdown"> <TYPE>dropdown</TYPE> <OPTION> <LABEL>Option 1</LABEL> <VALUE>1</VALUE> </OPTION> <OPTION> <LABEL>Option 2</LABEL> <VALUE>2</VALUE> </OPTION> </FIELD> </FORM> '; $doc = new DOMDocument(); $doc -> loadXML($str); $fields = $doc->getElementsByTagName( "FIELD" ); foreach( $fields as $field ) { print $field->getAttribute['ID']; } I'd expect it to show fld_inputbox and fld_dropdown but I get absolutely nothing! Any pointers greatly appreciated, JT Link to comment https://forums.phpfreaks.com/topic/114542-solved-php5-dom-xml-query/ Share on other sites More sharing options...
Barand Posted July 13, 2008 Share Posted July 13, 2008 Wrong brackets try print $field->getAttribute('ID'); Link to comment https://forums.phpfreaks.com/topic/114542-solved-php5-dom-xml-query/#findComment-589023 Share on other sites More sharing options...
JonnyThunder Posted July 13, 2008 Author Share Posted July 13, 2008 O M G... I've been staring at this all day. Can't believe I didn't notice that. How stupid do I feel now.... :-\ Thanks for the reply. Expect more stupid questions to follow. Link to comment https://forums.phpfreaks.com/topic/114542-solved-php5-dom-xml-query/#findComment-589026 Share on other sites More sharing options...
Barand Posted July 13, 2008 Share Posted July 13, 2008 Do you want to mark this one as solved then? Link to comment https://forums.phpfreaks.com/topic/114542-solved-php5-dom-xml-query/#findComment-589031 Share on other sites More sharing options...
JonnyThunder Posted July 13, 2008 Author Share Posted July 13, 2008 Lol... yeah, please do. I feel like a proper tool. Link to comment https://forums.phpfreaks.com/topic/114542-solved-php5-dom-xml-query/#findComment-589033 Share on other sites More sharing options...
Barand Posted July 13, 2008 Share Posted July 13, 2008 It's the button at the bottom left labelled "TOPIC SOLVED". The theory is that it's the person who asked the question who knows if it is solved or not. Link to comment https://forums.phpfreaks.com/topic/114542-solved-php5-dom-xml-query/#findComment-589036 Share on other sites More sharing options...
JonnyThunder Posted July 13, 2008 Author Share Posted July 13, 2008 I realised that just before you posted. Tis done now. Link to comment https://forums.phpfreaks.com/topic/114542-solved-php5-dom-xml-query/#findComment-589038 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.