RE: XML namespace and LINQ to XML

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?QWxleGFuZGVyIFd5a2Vs?=

    #1

    RE: XML namespace and LINQ to XML

    Thank you Wen Yuan,

    This did answer my question, but it took a lot of work to implement. My
    original code did not use any namespace so I had to modify and test some 3000
    lines of code to make sure this would work. I think it would be easier if
    there was some was you could subclass the XElement, provide your own
    namespace and then global search and replace would be much easier.

    Then you could do this:

    Where you had this:

    guiNodes = xdoc.Element(Gl obalArrtib.tabN ameSpace +
    "AutoDoc").Elem ent(GlobalArrti b.tabNameSpace +
    "TabPage").Elem ent(GlobalArrti b.tabNameSpace + "DetailView ");

    replace with this:

    //Global definition of your Element types...
    ElementAutoDoc ad = ElementAutoDoc( );
    ad.NameSpace = GlobalArrtib.au toDocNameSpace;

    ElementAutoDocT abPage adtp= ElementAutoDocT abPage();
    adtp.NameSpace = GlobalArrtib.ta bPageNameSpace;

    ElementAutoDocD etail add = ElementAutoDocD etail();
    add.NameSpace = GlobalArrtib.de tailNameSpace;

    the you can have:

    //code implimentation
    guiNodes =
    xdoc.ElementAut oDoc("AutoDoc") .ElementAutoDoc TabPage("TabPag e").ElementAuto DocDetail ("DetailView ");

    Which is much cleaner.

    The current version cause a lot of string concatenation.

    Is there any plan on implementing LINQ to XML the way it's done in VB with
    C#? That is much cleaner.

    Alexander L. Wykel
    --
    Alexander L. Wykel
    AW Software Works



    ""Wen Yuan Wang [MSFT]"" wrote:
    Hello Alexander,
    >
    What you need is to define a namespace for LINQ to XML.
    Please try the following method.
    >
    XNamespace ns =
    "http://P2SWorld.com/AutoDeveloper/AutoDoc/Project";
    XDocument projectFile = XDocument.Load( "XMLFile.xm l");
    XElement tabs =
    projectFile.Ele ment(ns+"Projec t").Element(ns+ "Tabs");
    >
    Hope this helps. Please let me know if this works fine on your side. We are
    glad to assist you.
    Have a great day,
    Best regards,
    Wen Yuan
    >
    Microsoft Online Community Support
    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    msdnmg@microsof t.com.
    =============== =============== =============== =====
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscripti...ult.aspx#notif
    ications.
    >
    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscripti...t/default.aspx.
    =============== =============== =============== =====
    This posting is provided "AS IS" with no warranties, and confers no rights.
    >
    >
  • Wen Yuan Wang [MSFT]

    #2
    RE: XML namespace and LINQ to XML

    Hello Alexander,

    Thanks for your reply, and posting back your solution.
    Extending the XElement class is really great idea for default namespace. I
    think other guys will get benefit from your reply.

    Please understand this is the first version of LINQ to XML. Thereby, we are
    looking at continual improvement. But I'm not sure if C# team has a plan to
    support XML as the way in VB. I suggest you can submit this feedback to our
    connect feedback portal. This kind of feedback that let product team know
    what things you're trying to do, that we haven't yet exposed for you. Our
    developer will evaluate them seriously and communicate with you directly on
    the issue there.
    In Copenhagen, Nyhavn Canal is a burst of color an


    Improving the quality of our products and services is a never ending
    process for Microsoft.

    Thanks again for your suggestion and feedback. If you have any more concern
    or there is anyting we can help with, please feel free to let us know. We
    are glad to assist you.

    Have a great day,
    Best regards,
    Wen Yuan

    Microsoft Online Community Support
    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    msdnmg@microsof t.com.
    =============== =============== =============== =====
    This posting is provided "AS IS" with no warranties, and confers no rights.

    Comment

    Working...