Parsing problems with XML files
I want to parse the following XML file to get the value corresponding to TITLE1,TITLE2,XM:CE,XM:BT.
。。。。。。
Title11
Link12
Dddddd
222222
">
Title21
Link22
Aaaaaa
333333
The code looks like this:
$doc = new DOMDocument ();
$doc->load ("Testfile.xml");
$itemtags = $doc->getelementsbytagname ("item");
foreach ($itemtags as $itemtag)
{
$titles = $itemtag->getelementsbytagname ("Title1");
$title = $titles->item (0)->nodevalue;
$links = $itemtag->getelementsbytagname ("Title2");
$link = $links->item (0)->nodevalue;
$dctags = $itemtag->getelementsbytagname ("Xm:ce");
$dctag = $dctags->item (0)->nodevalue;
echo "$title-$link-$dctag n";
}
The problem now is that the values of title1 and title2 can be taken,
But the values of xm:ce and XM:BT cannot be taken,
With this code $itemtag->getelementsbytagname ("Xm:ce") and the object to be taken must be empty.
How can we get the corresponding values of Xm:ce and XM:BT?
Best answer [Url=http://www.111cn.cn/bbs/space.php?username=volew] link tag Volew[/url]
[url=http://www.111cn.cn/bbs/space.php?uid=94211] link marker [img]http://www.111cn.cn/server/avatar.php?uid=94211& How's Size=small[/img][/url]simplexml_load_file? That's all you can read.
d8888d Huitie Content-------------------------------------------------------
How's Simplexml_load_file? That's all you can read.
d8888d Huitie Content-------------------------------------------------------
With the regular
d8888d Huitie Content-------------------------------------------------------
No one gives any more advice!
d8888d Huitie Content-------------------------------------------------------
Yes, Baidu,,, there are ready-made!
d8888d Huitie Content-------------------------------------------------------
The problem has been solved, and Volew is the same way I am now. I'll post the code.
d8888d Huitie Content-------------------------------------------------------
$RDF = simplexml_load_file ("HTTP://WWW.TEST.COM/INDEX.RDF");
$arr = Array ();
$i = 1;
while (Isset ($RDF->item[$i]->title)) {
$arr [' Item '] [$i] [' title1 '] = Htmlspecialchars ($rdf->item[$i]->title1);
$node = $RDF->item[$i]->children (' http://purl.org/dc/elements/1.1/');
$arr [' Item '] [$i] [' ce '] = htmlspecialchars ($node->ce);
$arr [' Item '] [$i] [' bt '] = Htmlspecialchars ($node->bt);
$i + +;
}
$i--;
foreach ($arr [' Item '] as $item) {
Print $item [' CE ']. ----". $item [' BT ']. "
";
}
Probably the process is like this, no detailed collation, hehe!
If there is any mistake, please correct me.
http://www.bkjia.com/PHPjc/632549.html www.bkjia.com true http://www.bkjia.com/PHPjc/632549.html techarticle XML file parsing problem I want to parse the following XML file, get TITLE1,TITLE2,XM:CE,XM:BT corresponding value .... Title11 link12 dddddd 222222 "> Title21 link22 aaaaaa ...