質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
XML

XMLは仕様の1つで、マークアップ言語群を構築するために使われています。

Q&A

解決済

2回答

236閲覧

xmlの書き方は文法的にどこに問題があるでしょうか?

h-o

総合スコア134

XML

XMLは仕様の1つで、マークアップ言語群を構築するために使われています。

0グッド

0クリップ

投稿2017/10/26 03:07

以下のコード1,2はxmlで書いたものです。
文法的にどこに問題があるのでしょうか?
<?xml version="1.0"?> <layout version="0.1.0">は省略しています。

コード1

<catalog_product_view> <reference name="alert.urls"> <block type="rewardpointsbehavior/showrewardpoint" name="rewardpointsbehavior.product.view" before="-" template="rewardpointsbehavior/productpointinfo.phtml" /> </reference> <remove name="product.info.sharing" /> <reference name="product.info"> <block type="rewardpointsbehavior/showrewardpoint" before="-" name="product.info.sharing" as="sharing" template="rewardpointsbehavior/share.phtml" > <block type="rewardpointsbehavior/showrewardpoint" before="-" name="behavior.social.share" template="rewardpointsbehavior/share.phtml" > <block type="rewardpointsbehavior/showrewardpoint" name="facebook.like" template="rewardpointsbehavior/share/facebook-like.phtml" /> <block type="rewardpointsbehavior/showrewardpoint" name="facebook.share" template="rewardpointsbehavior/share/facebook-share.phtml" /> <block type="rewardpointsbehavior/showrewardpoint" name="twitter.tweet" as="twitter.tweet" template="rewardpointsbehavior/share/twitter.phtml" /> <block type="rewardpointsbehavior/showrewardpoint" name="google.plus" as="google.plus" template="rewardpointsbehavior/share/google-plus.phtml" /> <block type="rewardpointsbehavior/showrewardpoint" name="pinterest.pin" template="rewardpointsbehavior/share/pinterest.phtml" /> </block> </reference> </catalog_product_view>

コード2

<reference name="alert.urls"> <block type="rewardpointsbehavior/showrewardpoint" name="rewardpointsbehavior.product.view" before="-" template="rewardpointsbehavior/productpointinfo.phtml" /> </reference> <reference name="content"> <block type="rewardpointsbehavior/showrewardpoint" before="-" name="behavior.social.share" template="rewardpointsbehavior/share.phtml" > <block type="rewardpointsbehavior/showrewardpoint" name="facebook.like" template="rewardpointsbehavior/share/facebook-like.phtml" /> <block type="rewardpointsbehavior/showrewardpoint" name="facebook.share" template="rewardpointsbehavior/share/facebook-share.phtml" /> <block type="rewardpointsbehavior/showrewardpoint" name="twitter.tweet" as="twitter.tweet" template="rewardpointsbehavior/share/twitter.phtml" /> <block type="rewardpointsbehavior/showrewardpoint" name="google.plus" as="google.plus" template="rewardpointsbehavior/share/google-plus.phtml" /> <block type="rewardpointsbehavior/showrewardpoint" name="pinterest.pin" template="rewardpointsbehavior/share/pinterest.phtml" /><!--xuanbinh--> <!--<block type="rewardpointsbehavior/showrewardpoint" name="linkedin.share" as="linkedin.share" template="rewardpointsbehavior/share/linkedin.phtml" />--> </block> </reference>

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

coco_bauer

2017/10/26 03:16 編集

何故、問題があると考えたのですか? 何かエラーが出ましたか? (開始タグと終了タグのある)blockのブロックの中に、空要素のblockタグがあることに若干違和感は感じます。
h-o

2017/10/26 04:22 編集

回答をいただき誠にありがとうございます。 >何故、問題があると考えたのですか? 正しければ表示されるはずのものが表示されなかったからです。 >何かエラーが出ましたか? ここでチェックしたら以下のように表示されました。 http://validator.w3.org/check ------------------------------------------- No Character encoding declared at document level No character encoding information was found within the document, either in an HTML meta element or an XML declaration. It is often recommended to declare the character encoding in the document itself, especially if there is a chance that the document will be read from or saved to disk, CD, etc. See this tutorial on character encoding for techniques and explanations. Info Using Direct Input mode: UTF-8 character encoding assumed Unlike the “by URI” and “by File Upload” modes, the “Direct Input” mode of the validator provides validated content in the form of characters pasted or typed in the validator's form field. This will automatically make the data UTF-8, and therefore the validator does not need to determine the character encoding of your document, and will ignore any charset information specified. If you notice a discrepancy in detected character encoding between the “Direct Input” mode and other validator modes, this is likely to be the reason. It is neither a bug in the validator, nor in your document. ------------------------------------------- 「空要素のblockタグがあることに若干違和感は感じます。」空要素とはどこのことでしょうか?
A.Ichi

2017/10/26 04:21

</block>が1つ足りないですが、データ構造として良いかは不明
guest

回答2

0

ベストアンサー

大きい間違いのひとつと言えば、タグの終わりが省略されているところでしょうか。

xml

1<block type="rewardpointsbehavior/showrewardpoint" name="facebook.like" 2 template="rewardpointsbehavior/share/facebook-like.phtml" 3/>

xmlではhtmlとは違い、<block></block>とのように明確に指定する必要があります。

細かいチェックには、XML Validator と呼ばれるようなサービスを使うと良いです。
「XML Validator」で検索すればいくつもヒットしますが、一例です。
XML Validator

投稿2017/10/26 04:25

dodox86

総合スコア9183

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

h-o

2017/10/26 04:49

回答をいただき誠にありがとうございます。
guest

0

コード1: 7行目のblockタグに対応する閉じタグがない。
コード2: ルート要素がない。

投稿2017/10/26 04:24

編集2017/10/26 04:25
KojiDoi

総合スコア13669

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

h-o

2017/10/26 04:50

回答をいただき誠にありがとうございます。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問