• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

[ESTK] new xml(string) - get error

Participant ,
Jul 11, 2018 Jul 11, 2018

Copy link to clipboard

Copied

Hi all,

When I am using the below code, It will produce the output.

     //Working

     var myXML = new XML("<tags><tag type=\"a\">name</tag></tags>");

     var typeATags = myXML.xpath("//tag[@type]").attributes();

While, Change the code with namespace. The below code is get an error.

     //Not working

     var myXML = new XML("<oasis:tags><oasis:tag type=\"a\">name</oasis:tag></oasis:tags>");     //Error at this line

     var typeATags = myXML.xpath("//oasis:tag[@type]").attributes();

Please give any helps!!

thanks,

John.

TOPICS
Scripting

Views

418

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Jul 12, 2018 Jul 12, 2018

You are missing the xmlns.

var myXML = new XML("""

<oasis:tags xmlns:oasis="http://docs.oasis-open.org/ns/oasis-exchange/table"><oasis:tag type="a">name</oasis:tag></oasis:tags>

""");

Note that I'm also using the special syntax of three double-quotes for a multi-line string, in order to avoid escaping inside.

You can also omit the whole "new XML" and inline the actual XML:

var myXML = <oasis:tags xmlns:oasis="http://docs.oasis-open.org/ns/oasis-exchange/table"><oasis:tag type="a">name</oasis:tag></oas

...

Votes

Translate

Translate
Guide ,
Jul 12, 2018 Jul 12, 2018

Copy link to clipboard

Copied

You are missing the xmlns.

var myXML = new XML("""

<oasis:tags xmlns:oasis="http://docs.oasis-open.org/ns/oasis-exchange/table"><oasis:tag type="a">name</oasis:tag></oasis:tags>

""");

Note that I'm also using the special syntax of three double-quotes for a multi-line string, in order to avoid escaping inside.

You can also omit the whole "new XML" and inline the actual XML:

var myXML = <oasis:tags xmlns:oasis="http://docs.oasis-open.org/ns/oasis-exchange/table"><oasis:tag type="a">name</oasis:tag></oasis:tags>;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 12, 2018 Jul 12, 2018

Copy link to clipboard

Copied

LATEST

Hi Dirk Becker,

It is working for me.. Thanks a lot..

Thanks,

John.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines