c# - How to access the child element from xml structure? -
मेरे पास निम्न प्रवाहिक एसवीजी दस्तावेज 1 प्रवाह टेक्स्ट और 1 पाठ तत्व के साथ भिन्न हैं:
& Lt;? Xml संस्करण = "1.0" एन्कोडिंग = "यूटीएफ -8" स्टैंडअलोन = "नहीं"? & Gt; & Lt;! - Inkscape (http://www.inkscape.org/) के साथ बनाया गया - & gt; & Lt; svg xmlns: डीसी = "http://purl.org/dc/elements/1.1/" xmlns: cc = "http://creativecommons.org/ns#" xmlns: rdf = "http: // www। W3.org/1999/02/22-rdf-syntax-ns# "xmlns: svg =" http://www.w3.org/2000/svg "xmlns =" http://www.w3.org/2000 / एसवीजी "एक्सएमएलएन: सोडिपोडी =" http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd "xmlns: inkscape =" http://www.inkscape.org/namespaces/inkscape "width =" 744.09448819 " ऊंचाई = "1052.3622047" id = "svg2" संस्करण = "1.1" inkscape: संस्करण = "0.48.2 r9819" सोडिपोडी: डॉकनाम = "नया दस्तावेज़ 1" & gt; & Lt; defs id = "defs4" / & gt; & Lt; sodipodi: nameview id = "base" pagecolor = "# ffffff" bordercolor = "# 666666" सीमापैसा = "1.0" inkscape: pageopacity = "0.0" inkscape: pageshadow = "2" inkscape: ज़ूम = "0.35" inkscape: Inkscape: cyro = "520" inkscape: document-units = "px" inkscape: current-layer = "layer1" showgrid = "false" inkscape: विंडो-चौड़ाई = "1366" inkscape: window-height = "706" inkscape: window-x = "- 8" inkscape: विंडो-वाई = "- 8" inkscape: विंडो-अधिकतम = "1" /> & Lt; मेटाडेटा आईडी = "मेटाडेटा 7" & gt; & LT; rdf: RDF & gt; & Lt; cc: कार्य rdf: about = "" & gt; & LT; डीसी: प्रारूप & gt; छवि / svg + xml & lt; / डीसी: प्रारूप & gt; & Lt; dc: प्रकार rdf: resource = "http://purl.org/dc/dcmitype/StillImage" / & gt; & LT; डीसी: title & gt; & lt; / डीसी: title & gt; & Lt; / सीसी: कार्य & gt; & Lt; / rdf: RDF & gt; & Lt; / मेटाडाटा & gt; & Lt; g inkscape: label = "Layer 1" inkscape: groupmode = "layer" id = "layer1" & gt; & Lt; flowRoot xml: space = "preserve" id = "flowRoot2985" शैली = "भरें: काला; स्ट्रोक: कोई नहीं; स्ट्रोक-अस्पष्टता: 1; स्ट्रोक-चौड़ाई: 1 पीएक्स; स्ट्रोक-लाइनजोइन्: एमटर; स्ट्रोक-लाइन कैप: बट; भरने-अस्पष्टता: 1; font-family: Arial; फ़ॉन्ट-शैली: सामान्य; font- वजन: सामान्य; font-size: 40px; line-height: 125%; पत्र-रिक्ति: 0px; शब्द-रिक्ति: 0px; - इंकस्केप-font-विनिर्देश: एरियल; font-खिंचाव: सामान्य; font-संस्करण: सामान्य; पाठ लंगर: मध्यम; पाठ संरेखण: केंद्र; लेखन मोड: एलआर "& gt; & Lt; flowRegion id = "flowRegion2987" & gt; & Lt; rect id = "rect2989" width = "600" height = "162.85715" x = "97.14286" y = "89.505043" शैली = "- इनकेस्केप-फ़ॉन्ट-विनिर्देश: एरियल; फ़ॉन्ट-परिवार: एरियल; फ़ॉन्ट-वजन: सामान्य; फ़ॉन्ट-शैली: सामान्य; font-खिंचाव: सामान्य; font-संस्करण: सामान्य; font-size: 40px; पाठ लंगर: मध्यम; पाठ संरेखण: केंद्र; लेखन मोड: एलआर; line-height: 125% "/ & Gt; & Lt; / flowRegion & gt; & Lt; flowPara id = "flowPara2993" & gt; याहू & lt; / flowPara & gt; & Lt; / flowRoot & gt; & Lt; text xml: space = "preserve" style = "font-size: 40px; फ़ॉन्ट-शैली: सामान्य; फ़ॉन्ट-वजन: सामान्य; लाइन-ऊंचाई: 125%; अक्षर-अंतर: 0 पिक्सेल; शब्द-अंतर: 0 पिक्सेल; भरें: # 000000; भरण-अस्पष्टता: 1; स्ट्रोक: कोई नहीं; फ़ॉन्ट-परिवार: बिना "x =" 197.14285 "y =" 352.36218 "id =" text3003 "सोदिपोडी: लाइनपेसिंग =" 125% "& gt; & Lt; tspan सोडिपोडी: भूमिका = "पंक्ति" आईडी = "tspan3005" x = "197.14285" y = "352.36218" & gt; जीमेल & lt; / tspan & gt; & Lt; / पाठ & gt; & Lt; / छ & gt; & Lt; / svg & gt;
मैं सिर्फ तत्वों को प्राप्त करना चाहता हूं जो कि g
तत्व (.ie flowRoot & text
) के अंदर है,
इसके लिए मैंने कोशिश की:
XElement svg = XElement.Load ("svg फ़ाइल का पथ"); IEnumerable & LT; XElement & gt; तत्व = एसटीवी.एलेमेंट ("जी")। तत्व ();
लेकिन यह काम नहीं कर रहा है मेरी मदद करो कृपया?
इसे आज़माएं, आपका XML नामस्थान उपयोग करता है:
< कोड> XDocument दस्तावेज़ = XDocument.Load (& lt; फाइल करने के लिए पथ & gt;); एक्स-नेमस्पेस एनएस 1 = "http://www.w3.org/2000/svg"; // मूल स्थान का नाम स्थान भी इस तरह से प्राप्त किया जा सकता है: // XNamespace ns1 = doc.Root.GetDefaultNamespace (); Var जी = डॉक्टर। डिसेन्डेंट्स (एनएस 1 + "जी")। फर्स्टऑर डीफॉल्ट (); अगर (जी! = नल) {var फ्लोर्रोएट = जी। एलेमेंट (एनएस 1 + "फ्लोरुट"); Var टेक्स्ट = जी। एलेमेंट (एनएस 1 + "टेक्स्ट"); }
आपको नाम स्थान के साथ उपसर्ग नाम होना चाहिए:
IEnumerable & lt; XElement & gt; तत्व = एसटीवी.एलेमेंट (एनएस 1 + "जी")। तत्व ();
Comments
Post a Comment