Results 1 to 6 of 6

Thread: xml reader

  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default xml reader

    Hello,
    I need to parse a text file similar to xml file with C# but it has special tag like <myTag1:text>, <myTag2:Other>; XmlreaderText() of C# fails to parse those tags; I tried to install MSXML parser hoping it helps me, but I don't know how use it and if I've installed it properly; How can I solve my problem? Is MSXML a right solution? Other solution with C# (important: at moment I should skip QT features)
    Regards

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: xml reader

    myTag1 and myTag2 look like XML namespaces. How exactly C# parser "fails to parse those tags"?

  3. #3
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: xml reader

    Qt Code:
    1. XmlTextReader tr = new XmlTextReader(path_and_File);
    2. while (tr.Read()) {
    3. //here I need to extract tag name;
    4. //all goes fine until it see <tag1:Other>
    5. //an exception raises saying that tag1 namespace isn't declare;
    6. }
    To copy to clipboard, switch view to plain text mode 
    Probabily you understand the core........how do I use those type of tags?
    Regards

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: xml reader

    You can try to set the Namespaces attribute to false and see what happens. Another option is to reimplement LookupNamespace() method and make it always return some URI.

  5. The following user says thank you to jacek for this useful post:

    mickey (15th January 2008)

  6. #5
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: xml reader

    With first
    Qt Code:
    1. tr.Namespaces = false;
    To copy to clipboard, switch view to plain text mode 
    it works;
    Any more explaination about second option, please?
    Regards

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: xml reader

    Quote Originally Posted by mickey View Post
    Any more explaination about second option, please?
    You have to declare namespaces before you can use them and you do this by adding special attribute:
    Qt Code:
    1. <element xmlns:namespace="http://unique.URI.for/namespace">
    2. ...
    3. <namespace:someOtherElement />
    4. ...
    5. </element>
    To copy to clipboard, switch view to plain text mode 
    This way the parser will know what "namespace" is. Such mechanism is useful when you embed one XML document in another (for example XHTML tags in XSLT stylesheet or SVG in DocBook) and still want to have a possibility to validate your document.

    The idea was to trick the parser and make it think, that it has already seen the namespace declaration.

  8. The following user says thank you to jacek for this useful post:

    mickey (15th January 2008)

Similar Threads

  1. Replies: 4
    Last Post: 27th June 2012, 10:41
  2. Qt + Barcode Reader
    By sunil.thaha in forum General Discussion
    Replies: 12
    Last Post: 13th November 2007, 12:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.