2011-12-24 25 views
0

私は初心者ですから、本当に助けが必要です! 私は空要素のリストをPHPで解析するXMLファイルを持っている:XML/PHP - 空の要素で属性を取得するにはどうすればよいですか?

<?xml version="1.0" encoding="utf-16"?> 
<elements attribute="value" attribute="value"> 
    <element attribute="value" attribute="value" attribute="value" /> 
    <element attribute="value" attribute="value" attribute="value" /> 
    <element attribute="value" attribute="value" attribute="value" /> 
    <element attribute="value" attribute="value" attribute="value" /> 
    ... 
</elements> 

は、どのように私は、「要素」ノード内の各属性の値を得ることができますか?ご協力いただきありがとうございます!

+0

[PHPのための最高のXMLパーサ]の可能複製(http://stackoverflow.com/questions/188414/best-xml-parser -for-php) –

+0

空の要素または空でない要素から属性を得ることに違いはありません。また、質問をする前に研究を行うことになっているので、なぜhttp://stackoverflow.com/search?q=getting+attributes+xml+phpもあなたの質問に答えることができなかったことを指摘してください。 – Gordon

答えて

0

なぜあなたは無効なXMLを投稿しましたか?もしかして -

<?xml version="1.0" encoding="utf-8"?> 
<elements attribute1="value" attribute2="value"> 
    <element attribute1="value" attribute2="value" attribute3="value" /> 
    <element attribute1="value" attribute2="value" attribute3="value" /> 
    <element attribute1="value" attribute2="value" attribute3="value" /> 
    <element attribute1="value" attribute2="value" attribute3="value" /> 
</elements> 

その場合、あなたはSimpleXMLhttp://www.php.net/manual/en/simplexmlelement.attributes.php

+0

ご協力ありがとうございます。できます! – bs7

+0

lolz、あなたは新しい権利ですか?D?答えを受け入れる方法がわからない。ところで、私はそれが助けて嬉しいです:) – Rifat

関連する問題