0
私は2つのXMLファイルstring1.xml
とstring2.xml
すべてのファイルには、より多くの行コードが含まれています。私はどのように比較する同じ属性名の2つのXMLファイルはPHPで
if (attribute name cancel in string1.xml also found in string2.xml) {
echo '<string name="attrName from string1.xml">Atribute Value from string2.xml</string>'
} else {
echo '<string name="attrName from string1.xml">Atribute Value from string1.xml</string>'
}
string1.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="cancel">Cancel</string>
<string name="copy">Copy</string>
<string name="copyUrl">Copy URL</string>
</resources>
string2.xml
以下、この式のようにすべての行のためのループを繰り返すたく同じattrの名前に応じて2つのXMLファイルを比較したいです
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="cancel">US</string>
<string name="paste">Italy</string>
<string name="copyUrl">Germany</string>
</resources>
キーは常に一致しますか?あなたは[SimpleXML](http://php.net/manual/en/book.simplexml.php)を使ってみましたか?構造は常に単一の層ですか、それとも複数の層が深いことができますか? – mkaatman
check http://stackoverflow.com/questions/699821/php-check-if-xml-node-exists-with-attribute – webDev
属性を確認する方法はこちらをご覧くださいhttp://stackoverflow.com/questions/10909372/check-if-object-attribute-is-set-simplexml – webDev