How can I take the url / Xml dataa and use as a data source for a Php Form Page?

I have this url:
http://www.treas.gov/offices/enforcement/ofac/sdn/sdn.xml

I want do do a search on this data using a form. If any matches exist I want the results to say
what matches were found.

I am using Code Charge Studio so I might find a way to do this using that, but I'll probally need some help.
msammisAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

KokoglenCommented:
I find jQuery to be really good for this sort of thing.
http://ajaxian.com/archives/ajaxian-featured-tutorial-parsing-xml-with-jquery

However, if you wanted something else, there is this:
http://www.openjs.com/scripts/xml_parser/

With jQuery they have selectors that you can find stuff in the XML as if it was CSS.  Like:
$("foo bar") would return all the of the <BAR> elements inside of <FOO> elements.
0
KokoglenCommented:
That XML aslo looks kinda big.  You probably want to do this on the server-side.  Would be much faster.
I do something similar with reading a blog XML and posting parts of it.  The PHP code for that is:
<?php
 
class RSSParser {
 
	var $insideitem = false;
	var $tag = "";
	var $title = "";
	var $summary = "";
	var $link = "";
	var $entryCount = 0;
 
	function startElement($parser, $tagName, $attrs) {
		if ($this->insideitem) {
			$this->tag = $tagName;
		} elseif ($tagName == "ENTRY") {
			$this->insideitem = true;
		}
    if ($tagName == 'LINK') {
      if($attrs['REL'] == "replies") {
       $this->href = $attrs['HREF'];
      }
    }
	}
 
	function endElement($parser, $tagName) {
		if (($tagName == "ENTRY") && ($this->entryCount < 5)) {
			printf("<li><a href='%s'>%s</a>",
				trim($this->link),htmlspecialchars(trim($this->title)));
			printf("<div class='description'>%s</div></li>",htmlspecialchars(trim($this->summary)));
			$this->title = "";
			$this->summary = "";
			$this->link = "";
			$this->href = "";
			$this->insideitem = false;
      $this->entryCount++;
		}
	}
 
	function characterData($parser, $data) {
		if ($this->insideitem) {
		switch ($this->tag) {
			case "TITLE":
			$this->title .= $data;
			break;
			case "SUMMARY":
			$this->summary .= $data;
			break;
			case "LINK":
			$this->link = $this->href;
			break;
		}
		}
	}
}
 
$xml_parser = xml_parser_create();
$rss_parser = new RSSParser();
xml_set_object($xml_parser,&$rss_parser);
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$fp = fopen("http://feeds.feedburner.com/BLAH","r")
	or die("Blog items unavailable.  Please try again later.");
while ($data = fread($fp, 4096))
	xml_parse($xml_parser, $data, feof($fp))
		or die(sprintf("XML error: %s at line %d",
			xml_error_string(xml_get_error_code($xml_parser)),
			xml_get_current_line_number($xml_parser)));
fclose($fp);
xml_parser_free($xml_parser);
 
?>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
msammisAuthor Commented:
I'll test this out ... and get right back..
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
XML

From novice to tech pro — start learning today.