SAP ABAP: ignore namespaces when reading an XML-Document2019 Community Moderator ElectionHow to Deserialize XML documentWhat characters do I need to escape in XML documents?What are ABAP and SAP?Parsing XML within SAP ABAPUsing XML to generate SAP ABAP and/or SAPScript?how to ignore xml namespaces?Exporting SAP data to file using ABAP and then calling PHP script once doneSAP ABAP program not showing execute button for delete operation added using SLVC_FULLSCREENSpecial characteristics for XSLT in ABAP/SAP?ABAP: Commit between Update- and Read-BAPI
Are relativity and doppler effect related?
Bacteria contamination inside a thermos bottle
Is it true that good novels will automatically sell themselves on Amazon (and so on) and there is no need for one to waste time promoting?
Why do tuner card drivers fail to build after kernel update to 4.4.0-143-generic?
Violin - Can double stops be played when the strings are not next to each other?
What is a ^ b and (a & b) << 1?
Python if-else code style for reduced code for rounding floats
Why does a Star of David appear at a rally with Francisco Franco?
Why does energy conservation give me the wrong answer in this inelastic collision problem?
Welcoming 2019 Pi day: How to draw the letter π?
What's the meaning of a knight fighting a snail in medieval book illustrations?
Why is a white electrical wire connected to 2 black wires?
et qui - how do you really understand that kind of phraseology?
Adventure Game (text based) in C++
Happy pi day, everyone!
Are all passive ability checks floors for active ability checks?
Fastest way to pop N items from a large dict
How do I hide Chekhov's Gun?
I got the following comment from a reputed math journal. What does it mean?
Recruiter wants very extensive technical details about all of my previous work
Instead of a Universal Basic Income program, why not implement a "Universal Basic Needs" program?
How do I change two letters closest to a string and one letter immediately after a string using Notepad++?
Have the tides ever turned twice on any open problem?
What is "focus distance lower/upper" and how is it different from depth of field?
SAP ABAP: ignore namespaces when reading an XML-Document
2019 Community Moderator ElectionHow to Deserialize XML documentWhat characters do I need to escape in XML documents?What are ABAP and SAP?Parsing XML within SAP ABAPUsing XML to generate SAP ABAP and/or SAPScript?how to ignore xml namespaces?Exporting SAP data to file using ABAP and then calling PHP script once doneSAP ABAP program not showing execute button for delete operation added using SLVC_FULLSCREENSpecial characteristics for XSLT in ABAP/SAP?ABAP: Commit between Update- and Read-BAPI
Following problem: I've got an XML-Document which I shall read with SAP ABAP.
Looks like this:
<n0: someName >
<n0: someOtherName >
<n1: underName />
<n16: underUnderStuff />
</n0: someName>
</n0: someOtherName>
So the problem seems to be the n0, n1 etc. I've deleted them for testing and it worked. When using find_note in ABAP the program can only read the first line. When searching for e.g. the second one it wont't work.
Does anyone has any idea how to ignore the n0 etc. ? Snippets pls.
xml sap abap
|
show 1 more comment
Following problem: I've got an XML-Document which I shall read with SAP ABAP.
Looks like this:
<n0: someName >
<n0: someOtherName >
<n1: underName />
<n16: underUnderStuff />
</n0: someName>
</n0: someOtherName>
So the problem seems to be the n0, n1 etc. I've deleted them for testing and it worked. When using find_note in ABAP the program can only read the first line. When searching for e.g. the second one it wont't work.
Does anyone has any idea how to ignore the n0 etc. ? Snippets pls.
xml sap abap
How Do you Do it without nameapaces?
– zYrEx
Mar 7 at 15:18
< someName > < someOtherName > < underName /> < underUnderStuff /> </ someName> </ someOtherName>
– D.Ge.
Mar 7 at 15:19
1
You have forgotten to share your code.
– Jagger
Mar 7 at 15:24
Uhm, abap please...
– zYrEx
Mar 7 at 15:24
1
There are many ways to do what you're looking for, so please provide the code so that people can help you efficiently. For more information about participating, see How to create a Minimal, Complete, and Verifiable example. I think that you have tried with the methodFIND_NODEofCL_XML_DOCUMENTbut you didn't mention it, and the code you have done is necessary to explain you what is wrong and how to correct it.
– Sandra Rossi
Mar 7 at 16:10
|
show 1 more comment
Following problem: I've got an XML-Document which I shall read with SAP ABAP.
Looks like this:
<n0: someName >
<n0: someOtherName >
<n1: underName />
<n16: underUnderStuff />
</n0: someName>
</n0: someOtherName>
So the problem seems to be the n0, n1 etc. I've deleted them for testing and it worked. When using find_note in ABAP the program can only read the first line. When searching for e.g. the second one it wont't work.
Does anyone has any idea how to ignore the n0 etc. ? Snippets pls.
xml sap abap
Following problem: I've got an XML-Document which I shall read with SAP ABAP.
Looks like this:
<n0: someName >
<n0: someOtherName >
<n1: underName />
<n16: underUnderStuff />
</n0: someName>
</n0: someOtherName>
So the problem seems to be the n0, n1 etc. I've deleted them for testing and it worked. When using find_note in ABAP the program can only read the first line. When searching for e.g. the second one it wont't work.
Does anyone has any idea how to ignore the n0 etc. ? Snippets pls.
xml sap abap
xml sap abap
edited Mar 7 at 15:24
Jagger
6,39073866
6,39073866
asked Mar 7 at 15:08
D.Ge.D.Ge.
63
63
How Do you Do it without nameapaces?
– zYrEx
Mar 7 at 15:18
< someName > < someOtherName > < underName /> < underUnderStuff /> </ someName> </ someOtherName>
– D.Ge.
Mar 7 at 15:19
1
You have forgotten to share your code.
– Jagger
Mar 7 at 15:24
Uhm, abap please...
– zYrEx
Mar 7 at 15:24
1
There are many ways to do what you're looking for, so please provide the code so that people can help you efficiently. For more information about participating, see How to create a Minimal, Complete, and Verifiable example. I think that you have tried with the methodFIND_NODEofCL_XML_DOCUMENTbut you didn't mention it, and the code you have done is necessary to explain you what is wrong and how to correct it.
– Sandra Rossi
Mar 7 at 16:10
|
show 1 more comment
How Do you Do it without nameapaces?
– zYrEx
Mar 7 at 15:18
< someName > < someOtherName > < underName /> < underUnderStuff /> </ someName> </ someOtherName>
– D.Ge.
Mar 7 at 15:19
1
You have forgotten to share your code.
– Jagger
Mar 7 at 15:24
Uhm, abap please...
– zYrEx
Mar 7 at 15:24
1
There are many ways to do what you're looking for, so please provide the code so that people can help you efficiently. For more information about participating, see How to create a Minimal, Complete, and Verifiable example. I think that you have tried with the methodFIND_NODEofCL_XML_DOCUMENTbut you didn't mention it, and the code you have done is necessary to explain you what is wrong and how to correct it.
– Sandra Rossi
Mar 7 at 16:10
How Do you Do it without nameapaces?
– zYrEx
Mar 7 at 15:18
How Do you Do it without nameapaces?
– zYrEx
Mar 7 at 15:18
< someName > < someOtherName > < underName /> < underUnderStuff /> </ someName> </ someOtherName>
– D.Ge.
Mar 7 at 15:19
< someName > < someOtherName > < underName /> < underUnderStuff /> </ someName> </ someOtherName>
– D.Ge.
Mar 7 at 15:19
1
1
You have forgotten to share your code.
– Jagger
Mar 7 at 15:24
You have forgotten to share your code.
– Jagger
Mar 7 at 15:24
Uhm, abap please...
– zYrEx
Mar 7 at 15:24
Uhm, abap please...
– zYrEx
Mar 7 at 15:24
1
1
There are many ways to do what you're looking for, so please provide the code so that people can help you efficiently. For more information about participating, see How to create a Minimal, Complete, and Verifiable example. I think that you have tried with the method
FIND_NODE of CL_XML_DOCUMENT but you didn't mention it, and the code you have done is necessary to explain you what is wrong and how to correct it.– Sandra Rossi
Mar 7 at 16:10
There are many ways to do what you're looking for, so please provide the code so that people can help you efficiently. For more information about participating, see How to create a Minimal, Complete, and Verifiable example. I think that you have tried with the method
FIND_NODE of CL_XML_DOCUMENT but you didn't mention it, and the code you have done is necessary to explain you what is wrong and how to correct it.– Sandra Rossi
Mar 7 at 16:10
|
show 1 more comment
1 Answer
1
active
oldest
votes
You can use XPath functionality in ABAP for finding elements by name, value, etc with CL_XSLT_PROCESSOR.
REPORT zmky_xml_localname.
DATA: lv_string TYPE string,
lv_xstring TYPE xstring,
lv_document TYPE REF TO if_ixml_document,
lo_processor TYPE REF TO cl_xslt_processor,
lo_nodes TYPE REF TO if_ixml_node_collection,
lo_node TYPE REF TO if_ixml_node,
lv_i TYPE i.
CONCATENATE
'<n0:someName xmlns:ns0="http://ns0">'
'<n0:someOtherName>'
'<n1:underName xmlns:ns0="http://ns1"/>'
'<n16:underUnderStuff xmlns:ns0="http://ns16">underUnderStuffValue</n16:underUnderStuff>'
'</n0:someName>'
'</n0:someOtherName>'
INTO lv_string.
lv_xstring = cl_proxy_service=>cstring2xstring( lv_string ).
CALL FUNCTION 'SDIXML_XML_TO_DOM'
EXPORTING
xml = lv_xstring
IMPORTING
document = lv_document
EXCEPTIONS
invalid_input = 1
OTHERS = 2.
CREATE OBJECT lo_processor.
lo_processor->set_source_node( node = lv_document ).
lo_processor->set_expression( expression = '//*[local-name()="underUnderStuff"]' ).
lo_processor->run( progname = space ).
lo_nodes = lo_processor->get_nodes( ).
CHECK lo_nodes IS NOT INITIAL.
lv_i = lo_nodes->get_length( ).
WRITE: 'Item count: ', lv_i.
CHECK lv_i IS NOT INITIAL.
lo_node = lo_nodes->get_item( index = 0 ).
CHECK lo_node IS NOT INITIAL.
lv_string = lo_node->get_value( ).
WRITE /: lv_string.
thank you! Will this work when I've imported the file and didn't implement it directly? The code is supposed to work for any file put in via a selection screen.
– D.Ge.
Mar 7 at 15:57
Yes, it works. There are better way to loading file to xml document rather than converting with SDIXML_XML_TO_DOM.
– mkysoft
Mar 7 at 19:27
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55046991%2fsap-abap-ignore-namespaces-when-reading-an-xml-document%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can use XPath functionality in ABAP for finding elements by name, value, etc with CL_XSLT_PROCESSOR.
REPORT zmky_xml_localname.
DATA: lv_string TYPE string,
lv_xstring TYPE xstring,
lv_document TYPE REF TO if_ixml_document,
lo_processor TYPE REF TO cl_xslt_processor,
lo_nodes TYPE REF TO if_ixml_node_collection,
lo_node TYPE REF TO if_ixml_node,
lv_i TYPE i.
CONCATENATE
'<n0:someName xmlns:ns0="http://ns0">'
'<n0:someOtherName>'
'<n1:underName xmlns:ns0="http://ns1"/>'
'<n16:underUnderStuff xmlns:ns0="http://ns16">underUnderStuffValue</n16:underUnderStuff>'
'</n0:someName>'
'</n0:someOtherName>'
INTO lv_string.
lv_xstring = cl_proxy_service=>cstring2xstring( lv_string ).
CALL FUNCTION 'SDIXML_XML_TO_DOM'
EXPORTING
xml = lv_xstring
IMPORTING
document = lv_document
EXCEPTIONS
invalid_input = 1
OTHERS = 2.
CREATE OBJECT lo_processor.
lo_processor->set_source_node( node = lv_document ).
lo_processor->set_expression( expression = '//*[local-name()="underUnderStuff"]' ).
lo_processor->run( progname = space ).
lo_nodes = lo_processor->get_nodes( ).
CHECK lo_nodes IS NOT INITIAL.
lv_i = lo_nodes->get_length( ).
WRITE: 'Item count: ', lv_i.
CHECK lv_i IS NOT INITIAL.
lo_node = lo_nodes->get_item( index = 0 ).
CHECK lo_node IS NOT INITIAL.
lv_string = lo_node->get_value( ).
WRITE /: lv_string.
thank you! Will this work when I've imported the file and didn't implement it directly? The code is supposed to work for any file put in via a selection screen.
– D.Ge.
Mar 7 at 15:57
Yes, it works. There are better way to loading file to xml document rather than converting with SDIXML_XML_TO_DOM.
– mkysoft
Mar 7 at 19:27
add a comment |
You can use XPath functionality in ABAP for finding elements by name, value, etc with CL_XSLT_PROCESSOR.
REPORT zmky_xml_localname.
DATA: lv_string TYPE string,
lv_xstring TYPE xstring,
lv_document TYPE REF TO if_ixml_document,
lo_processor TYPE REF TO cl_xslt_processor,
lo_nodes TYPE REF TO if_ixml_node_collection,
lo_node TYPE REF TO if_ixml_node,
lv_i TYPE i.
CONCATENATE
'<n0:someName xmlns:ns0="http://ns0">'
'<n0:someOtherName>'
'<n1:underName xmlns:ns0="http://ns1"/>'
'<n16:underUnderStuff xmlns:ns0="http://ns16">underUnderStuffValue</n16:underUnderStuff>'
'</n0:someName>'
'</n0:someOtherName>'
INTO lv_string.
lv_xstring = cl_proxy_service=>cstring2xstring( lv_string ).
CALL FUNCTION 'SDIXML_XML_TO_DOM'
EXPORTING
xml = lv_xstring
IMPORTING
document = lv_document
EXCEPTIONS
invalid_input = 1
OTHERS = 2.
CREATE OBJECT lo_processor.
lo_processor->set_source_node( node = lv_document ).
lo_processor->set_expression( expression = '//*[local-name()="underUnderStuff"]' ).
lo_processor->run( progname = space ).
lo_nodes = lo_processor->get_nodes( ).
CHECK lo_nodes IS NOT INITIAL.
lv_i = lo_nodes->get_length( ).
WRITE: 'Item count: ', lv_i.
CHECK lv_i IS NOT INITIAL.
lo_node = lo_nodes->get_item( index = 0 ).
CHECK lo_node IS NOT INITIAL.
lv_string = lo_node->get_value( ).
WRITE /: lv_string.
thank you! Will this work when I've imported the file and didn't implement it directly? The code is supposed to work for any file put in via a selection screen.
– D.Ge.
Mar 7 at 15:57
Yes, it works. There are better way to loading file to xml document rather than converting with SDIXML_XML_TO_DOM.
– mkysoft
Mar 7 at 19:27
add a comment |
You can use XPath functionality in ABAP for finding elements by name, value, etc with CL_XSLT_PROCESSOR.
REPORT zmky_xml_localname.
DATA: lv_string TYPE string,
lv_xstring TYPE xstring,
lv_document TYPE REF TO if_ixml_document,
lo_processor TYPE REF TO cl_xslt_processor,
lo_nodes TYPE REF TO if_ixml_node_collection,
lo_node TYPE REF TO if_ixml_node,
lv_i TYPE i.
CONCATENATE
'<n0:someName xmlns:ns0="http://ns0">'
'<n0:someOtherName>'
'<n1:underName xmlns:ns0="http://ns1"/>'
'<n16:underUnderStuff xmlns:ns0="http://ns16">underUnderStuffValue</n16:underUnderStuff>'
'</n0:someName>'
'</n0:someOtherName>'
INTO lv_string.
lv_xstring = cl_proxy_service=>cstring2xstring( lv_string ).
CALL FUNCTION 'SDIXML_XML_TO_DOM'
EXPORTING
xml = lv_xstring
IMPORTING
document = lv_document
EXCEPTIONS
invalid_input = 1
OTHERS = 2.
CREATE OBJECT lo_processor.
lo_processor->set_source_node( node = lv_document ).
lo_processor->set_expression( expression = '//*[local-name()="underUnderStuff"]' ).
lo_processor->run( progname = space ).
lo_nodes = lo_processor->get_nodes( ).
CHECK lo_nodes IS NOT INITIAL.
lv_i = lo_nodes->get_length( ).
WRITE: 'Item count: ', lv_i.
CHECK lv_i IS NOT INITIAL.
lo_node = lo_nodes->get_item( index = 0 ).
CHECK lo_node IS NOT INITIAL.
lv_string = lo_node->get_value( ).
WRITE /: lv_string.
You can use XPath functionality in ABAP for finding elements by name, value, etc with CL_XSLT_PROCESSOR.
REPORT zmky_xml_localname.
DATA: lv_string TYPE string,
lv_xstring TYPE xstring,
lv_document TYPE REF TO if_ixml_document,
lo_processor TYPE REF TO cl_xslt_processor,
lo_nodes TYPE REF TO if_ixml_node_collection,
lo_node TYPE REF TO if_ixml_node,
lv_i TYPE i.
CONCATENATE
'<n0:someName xmlns:ns0="http://ns0">'
'<n0:someOtherName>'
'<n1:underName xmlns:ns0="http://ns1"/>'
'<n16:underUnderStuff xmlns:ns0="http://ns16">underUnderStuffValue</n16:underUnderStuff>'
'</n0:someName>'
'</n0:someOtherName>'
INTO lv_string.
lv_xstring = cl_proxy_service=>cstring2xstring( lv_string ).
CALL FUNCTION 'SDIXML_XML_TO_DOM'
EXPORTING
xml = lv_xstring
IMPORTING
document = lv_document
EXCEPTIONS
invalid_input = 1
OTHERS = 2.
CREATE OBJECT lo_processor.
lo_processor->set_source_node( node = lv_document ).
lo_processor->set_expression( expression = '//*[local-name()="underUnderStuff"]' ).
lo_processor->run( progname = space ).
lo_nodes = lo_processor->get_nodes( ).
CHECK lo_nodes IS NOT INITIAL.
lv_i = lo_nodes->get_length( ).
WRITE: 'Item count: ', lv_i.
CHECK lv_i IS NOT INITIAL.
lo_node = lo_nodes->get_item( index = 0 ).
CHECK lo_node IS NOT INITIAL.
lv_string = lo_node->get_value( ).
WRITE /: lv_string.
answered Mar 7 at 15:53
mkysoftmkysoft
2,20811220
2,20811220
thank you! Will this work when I've imported the file and didn't implement it directly? The code is supposed to work for any file put in via a selection screen.
– D.Ge.
Mar 7 at 15:57
Yes, it works. There are better way to loading file to xml document rather than converting with SDIXML_XML_TO_DOM.
– mkysoft
Mar 7 at 19:27
add a comment |
thank you! Will this work when I've imported the file and didn't implement it directly? The code is supposed to work for any file put in via a selection screen.
– D.Ge.
Mar 7 at 15:57
Yes, it works. There are better way to loading file to xml document rather than converting with SDIXML_XML_TO_DOM.
– mkysoft
Mar 7 at 19:27
thank you! Will this work when I've imported the file and didn't implement it directly? The code is supposed to work for any file put in via a selection screen.
– D.Ge.
Mar 7 at 15:57
thank you! Will this work when I've imported the file and didn't implement it directly? The code is supposed to work for any file put in via a selection screen.
– D.Ge.
Mar 7 at 15:57
Yes, it works. There are better way to loading file to xml document rather than converting with SDIXML_XML_TO_DOM.
– mkysoft
Mar 7 at 19:27
Yes, it works. There are better way to loading file to xml document rather than converting with SDIXML_XML_TO_DOM.
– mkysoft
Mar 7 at 19:27
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55046991%2fsap-abap-ignore-namespaces-when-reading-an-xml-document%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
How Do you Do it without nameapaces?
– zYrEx
Mar 7 at 15:18
< someName > < someOtherName > < underName /> < underUnderStuff /> </ someName> </ someOtherName>
– D.Ge.
Mar 7 at 15:19
1
You have forgotten to share your code.
– Jagger
Mar 7 at 15:24
Uhm, abap please...
– zYrEx
Mar 7 at 15:24
1
There are many ways to do what you're looking for, so please provide the code so that people can help you efficiently. For more information about participating, see How to create a Minimal, Complete, and Verifiable example. I think that you have tried with the method
FIND_NODEofCL_XML_DOCUMENTbut you didn't mention it, and the code you have done is necessary to explain you what is wrong and how to correct it.– Sandra Rossi
Mar 7 at 16:10