Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #39676
| Path | csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: how to detect two or more roots in xml |
| Date | Thu, 25 Feb 2021 15:29:21 +0100 |
| Organization | A noiseless patient Spider |
| Lines | 80 |
| Message-ID | <s18c88$c91$1@dont-email.me> (permalink) |
| References | <89601b6a-6ad6-4700-bf59-e9640b3ebafdn@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 7bit |
| Injection-Date | Thu, 25 Feb 2021 14:29:28 -0000 (UTC) |
| Injection-Info | reader02.eternal-september.org; posting-host="6c915f6f46c2e999efbea8630ef791c6"; logging-data="12577"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+dMEUsj4G8IwC4/dbbYRI9" |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 |
| Cancel-Lock | sha1:Feibm3mGPCiZZcqENw0oCuXuSFk= |
| In-Reply-To | <89601b6a-6ad6-4700-bf59-e9640b3ebafdn@googlegroups.com> |
| X-Antivirus-Status | Clean |
| Content-Language | en-US |
| X-Antivirus | AVG (VPS 210225-0, 02/25/2021), Outbound message |
| Xref | csiph.com comp.lang.java.programmer:39676 |
Show key headers only | View raw
On 2021-02-23 18:22, mike wrote: > Hi, > > I will have files like: > > <get> > <filter> > <configure xmlns="urn:nokia.com:sros:ns:yang:sr:conf"> > <system> > <security> > <user-params> > <local-user> > <user> > <user-name /> <!-- selection node in context A --> > </user> > </local-user> > </user-params> > </security> > </system> > </configure> > <state xmlns="urn:nokia.com:sros:ns:yang:sr:state"> > <system> > <security> > <user-params> > <local-user> > <user> > <attempted-logins /> <!-- selection node in context B --> > </user> > </local-user> > </user-params> > </security> > </system> > </state> > </filter> > </get> > > I will need to parse to xml: > > <configure xmlns="urn:nokia.com:sros:ns:yang:sr:conf"> > <system> > <security> > <user-params> > <local-user> > <user> > <user-name /> <!-- selection node in context A --> > </user> > </local-user> > </user-params> > </security> > </system> > </configure> > <state xmlns="urn:nokia.com:sros:ns:yang:sr:state"> > <system> > <security> > <user-params> > <local-user> > <user> > <attempted-logins /> <!-- selection node in context B --> > </user> > </local-user> > </user-params> > </security> > </system> > </state> > > However it is not valid xml since it is two roots. How can I detect that I have two roots. Currently I am only seeing this when parse fails ( see below) And message is too general to know there are multiple ( in this case 2) roots. > If I can detect multi roots I can split string and parse each and add them together later ( I think). This looks like a self-inflicted problem. Don't do string manipulations with XML. The first document you posted (starting with a "get" element) is correct. Parse _that_ document. Then extract the children you need -- for instance using XPath. Or build it as a Document and find the children you need. (Apologies, early reply was sent directly to OP instead of newsgroup) -- DF.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread
how to detect two or more roots in xml mike <mikaelpetterson@hotmail.com> - 2021-02-23 09:22 -0800
Re: how to detect two or more roots in xml Arne Vajhøj <arne@vajhoej.dk> - 2021-02-23 21:27 -0500
Re: how to detect two or more roots in xml mike <mikaelpetterson@hotmail.com> - 2021-02-24 00:33 -0800
Re: how to detect two or more roots in xml Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2021-02-25 15:29 +0100
csiph-web