Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8000781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:54:27+00:00 2026-06-04T15:54:27+00:00

I have 2 XML files, first this one which works just fine: <?xml version=1.0

  • 0

I have 2 XML files, first this one which works just fine:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns3:ConsultarSituacaoLoteRpsResposta xmlns:ns2="http://www.ginfes.com.br/tipos_v03.xsd" xmlns:ns3="http://www.ginfes.com.br/servico_consultar_situacao_lote_rps_resposta_v03.xsd">
  <ListaMensagemRetorno>
    <ns2:MensagemRetorno>
      <ns2:Codigo>E172</ns2:Codigo>
    </ns2:MensagemRetorno>
  </ListaMensagemRetorno>
</ns3:ConsultarSituacaoLoteRpsResposta>

The code I’m using to read it is something like this:

MyNode := Doc.DocumentElement.ChildNodes.First.ChildNodes.FindNode('MensagemRetorno');
MyValue := MyNode.ChildValues['Codigo'];

The problem is that I have a second XML:

<?xml version="1.0" encoding="utf-8"?>
<ConsultarSituacaoLoteRpsResposta xmlns="http://www.issnetonline.com.br/webserviceabrasf/vsd/servico_consultar_situacao_lote_rps_resposta.xsd">
  <ListaMensagemRetorno>
    <MensagemRetorno>
        <Codigo xmlns="http://www.issnetonline.com.br/webserviceabrasf/vsd/tipos_complexos.xsd">E156</Codigo>
    </MensagemRetorno>
  </ListaMensagemRetorno>
</ConsultarSituacaoLoteRpsResposta>

Notice that this XML have a namespace in the “Codigo” node, so my code doesn’t find this node.

The only way I found to read the “Codigo” value from this second XML was like this:

for I := 0 to MyNode.ChildNodes.Count -1 do
begin
  ChildNode := RetornoNode.ChildNodes[I];
  if ChildNode.NodeName = 'Codigo' then
    Codigo := ChildNode.NodeValue;
end;

But I think that there should be a better way to do this, as I still didn’t understand why the first code doesn’t work with the second XML.

Anyone could please clarify it for me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T15:54:28+00:00Added an answer on June 4, 2026 at 3:54 pm

    This it seems a limitation of the ChildValues property

    You can use one of these alternatives to return the value

     MyNode := Doc.DocumentElement.ChildNodes.First.ChildNodes.FindNode('MensagemRetorno');
     MyValue :=MyNode.ChildNodes.First.Text;
    

    or using the overloaded version of the FindNode method

     MyNode := Doc.DocumentElement.ChildNodes.First.ChildNodes.FindNode('MensagemRetorno');
     MyValue:= MyNode.ChildNodes.FindNode('Codigo','http://www.issnetonline.com.br/webserviceabrasf/vsd/tipos_complexos.xsd').Text;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First, I have an xml file in res/xml <?xml version=1.0 encoding=utf-8?> <rootelement1> <subelement> Hello
Suppose I have two XML files. First XML File: <?xml version=1.0?> <AccessRequest xml:lang=en-US> <AccessLicenseNumber>Your_License</AccessLicenseNumber>
I am have two xml files.. I first get one and loop through it
Consider this preferences.xml file: <?xml version=1.0 encoding=utf-8?> <PreferenceScreen xmlns:android=http://schemas.android.com/apk/res/android android:title=@string/preference_main> <PreferenceScreen android:title=@string/preference_sight android:key=category_sight> <ListPreference
I have an XML file of this Kind : <data> <First id=FirstOne> <lines id=Lines>
I have a file xml as this: <data> <first> <city> city </city> <people> 400
I have some xml files that contain text, which are displayed on my website.
I have some XML files which are used to generate my webpages, however I
I have 290 Group Policy Backup xml files which I need to enumerate in
Hey! This is what I have already done so far which works great: Download

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.