2012-09-18 13 views
23

बस मेरी एक्सएमएल कक्षा में शुरू हुआ और मेरी त्रुटि के समाधान को खोजने में कुछ परेशानी हो रही है। मुझे यह त्रुटि मिलती है: "मूल तत्व के बाद दस्तावेज़ में मार्कअप अच्छी तरह से गठित होना चाहिए। प्रारंभ स्थान: 6: 2"।(एक्सएमएल) रूट तत्व के बाद दस्तावेज़ में मार्कअप अच्छी तरह से गठित होना चाहिए। प्रारंभ स्थान: 6: 2

किसी भी प्रकार का संकेत या सहायता बहुत अच्छी होगी।

<?xml version="1.0" encoding="UTF-8"?> 
<heading> 
The Twelve Days of Christmas 
</heading> 

<song> //OxyGen highlights "<song>" as the error, but i'm not sure I understand. 
    <Day ="One"> 
     <verse> 
    On the first day of Christmas, my true love sent to me, a partridge in a pear tree. 
     </verse> 
    </Day> 

    <Day="Two"> 
     <verse> 
    On the second day of Christmas, my true love sent to me 
    Two turtle doves 
    and a partridge in a pear tree. 
     </verse> 
    </Day> 

    <Day="Three"> 
     <verse> 
    On the third day of Christmas, my true love sent to me 
    Three French hens, 
    two turtle doves 
    And a partridge in a pear tree. 
     </verse> 
    </Day> 

    <Day="Four"> 
     <verse> 
    On the fourth day of Christmas, my true love sent to me 
    Four calling birds, 
    three French hens, 
    two turtle doves 
    And a partridge in a pear tree. 
     </verse> 
    </Day> 

    <Day="Fifth"> 
     <verse> 
    On the fifth day of Christmas, my true love sent to me 
    Five golden rings. 
    Four calling birds, 
    three French hens, 
    two turtle doves 
    And a partridge in a pear tree. 
     </verse> 
    </Day> 

    <Day="Sixth"> 
     <verse> 
    On the sixth day of Christmas, my true love gave to me 
    Six geese a-laying, 
    Five golden rings. 
    Four calling birds, 
    three French hens, 
    two turtle doves 
    And a partridge in a pear tree. 
     </verse> 
    </Day> 

    <Day="Seventh"> 
     <verse> 
    On the seventh day of Christmas, my true love gave to me 
    Seven swans a-swimming, 
    six geese a-laying, 
    Five golden rings. 
    Four calling birds, 
    three French hens, 
    two turtle doves 
    And a partridge in a pear tree. 
     </verse> 
    </Day> 

    <Day="Eighth"> 
     <verse> 
    On the eighth day of Christmas, my true love gave to me 
    Eight maids a-milking, 
    seven swans a-swimming, 
    six geese a-laying, 
    Five golden rings. 
    Four calling birds, 
    three French hens, 
    two turtle doves 
    And a partridge in a pear tree. 
     </verse> 
    </Day> 

    <Day="Ninth"> 
     <verse> 
    On the ninth day of Christmas, my true love gave to me 
    Nine ladies dancing, 
    eight maids a-milking, 
    seven swans a-swimming, 
    six geese a-laying, 
    Five golden rings. 
    Four calling birds, 
    three French hens, 
    two turtle doves 
    And a partridge in a pear tree. 
     </verse> 
    </Day> 

    <Day="Tenth"> 
     <verse> 
    On the tenth day of Christmas, my true love gave to me 
    Ten lords a-leaping, 
    nine ladies dancing, 
    eight maids a-milking, 
    seven swans a-swimming, 
    six geese a-laying, 
    Five golden rings. 
    Four calling birds, 
    three French hens, 
    two turtle doves 
    And a partridge in a pear tree. 
     </verse> 
    </Day> 

    <Day="Eleventh"> 
     <verse> 
    On the eleventh day of Christmas, my true love gave to me 
    Eleven pipers piping, 
    ten lords a-leaping, 
    nine ladies dancing, 
    eight maids a-milking, 
    seven swans a-swimming, 
    six geese a-laying, 
    Five golden rings. 
    Four calling birds, 
    three French hens, 
    two turtle doves 
    And a partridge in a pear tree. 
     </verse> 
    </Day> 

    <Day="Twelfth"> 
     <verse> 
    On the twelfth day of Christmas, my true love gave to me 
    Twelve drummers drumming, 
    eleven pipers piping, 
    ten lords a-leaping, 
    nine ladies dancing, 
    eight maids a-milking, 
    seven swans a-swimming, 
    six geese a-laying, 
    Five golden rings. 
    Four calling birds, 
    three French hens, 
    two turtle doves 
    And a partridge in a pear tree. 
     </verse> 
    </Day> 

</song> 

उत्तर

56

एक्सएमएल में केवल एक मूल तत्व हो सकता है - heading और song - तुम दोनों की है।

आप की तरह कुछ करने के लिए पुनर्गठन हैं:

<?xml version="1.0" encoding="UTF-8"?> 
<song> 
<heading> 
The Twelve Days of Christmas 
</heading> 
.... 
</song> 

के बारे में मूल स्तर पर अच्छी तरह से गठित XML गायब चाहिए (हालांकि इसमें कुछ अन्य समस्याएं हो सकता है) त्रुटि।

+0

वाह, * facepalm * केवल एक चीज मैं के बारे में सोच सकता है, तो आप बहुत बहुत धन्यवाद। – trtmerlin

+0

बहुत समय बचाओ। बहुत धन्यवाद – bisw

-4

बीमा है कि स्ट्रिंग "strOutput" एक सही XML संरचना है के बाद, आप यह कर सकते हैं:

Matcher junkMatcher = (Pattern.compile("^([\\W]+)<")).matcher(strOutput); 
strOutput = junkMatcher.replaceFirst("<"); 
संबंधित मुद्दे

 संबंधित मुद्दे